Giter Site home page Giter Site logo

mmm-rest's People

Contributors

dathbe avatar kristjanesperanto avatar marcuswillberg avatar mueller-ma avatar tuxdiver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mmm-rest's Issues

Issues displaying OpenHAB items

this is my config.
But i can't see any output on the mirror

		{
        module: 'MMM-Rest',
        position: 'top_right',
        config: {
			debug: false,
			sections: [
			{
				format: '%.1f<span class="wi wi-celsius"></span>',
				url: 'http://openhab:8080/rest/items/mqtt_temp_LivingRoom/state',
			},
			{
				format: '%d%%',
				url: 'http://openhab:8080/rest/items/mqtt_humi_LivingRoom/state',
			},
			{
				format: '%.1f<span class="wi wi-celsius"></span>',
				url: 'http://openhab:8080/rest/items/mqtt_temp_Bathroom/state',
			},
			{
				format: '%d%%',
				url: 'http://openhab:8080/rest/items/mqtt_humi_Bathroom/state',
			},
			],
			output: [
				['Wohnzimmer','@1','@2'],
				['Bad','@3','@4']
			]
        }
		},

PR request or Fork?

I solved the multiple instances issues by passing a unique id through the update notifications. I can either create a PR for you to add this into your module, or I can create a new fork module called "Rest2". Your call.

REQUEST: Audible notification

First of thank you for your build it is awesome. I was wanting to see if there is anyway to add an audible sound when the temperature reaches one of the ranges that have been set in the config.js. Thanks in advance.

Still working for OpenHAB?

Is this still working for OpenHAB? I suspect this was built and last updated before OH added authorization, and I'm not getting reliable connections without passing an authorization header. I'm curiously getting only sporadic values returned, with most of my entries showing "..." most of the time. Though which entries show "..." changes.

Display strings?

Hi,
is it possible to display strings and to "translate" them?

e.g. OpenHAB gives me "OPEN" or "CLOSED" via rest api, but mmm-rest displays "NaN". It would be great, if the addon could handle simple word replacement (e.g. "OPEN" => "geöffnet")

Better cell alignment?

I made another change, which addresses how cells are aligned. As I understand the current code, if the cell contains an '@' section id variable, it will align the cell to the right, otherwise it will align the cell to the left. This works well when the row is of the format [description, variable]. But if the use case calls for [variable, description] (e.g., "5 bananas"), or [variable, variable] (my use case because the description changes based on some factors), the alignment isn't right. I THINK it makes more sense have left columns aligned left, and right columns aligned right, so I've made a change to do that here:
https://github.com/dathbe/MMM-Rest/tree/patch-1
I will create a PR if you think this is an improvement.

Module keeps "Loading" forever

The configured URL resolves correctly using curl and gives back the required info (temperatur from an aquarium).

{
        module: 'MMM-Rest',
        position: 'bottom_right',               // This can be any of the regions.
                config: {
               debug: true,
            sections: [
                {
                    suffix: 'ºC',
                    digits: 1,
                    url: 'http://192.168.1.4:8000/devices/temp2/sensor/temperature/c'
                },
            ],
            output: [
                ['Temperatura Acuario','@1']
            ],
                }
},

Node-red connection

So I'd like to display my sensor values from home-assistant or node-red (I get them via MQTT btw) on a magic mirror....

I have several questions, first, can I display multiple values or just 3 like in the example?

Second, how do I need to construct the url so that this module will pick it up and display it? Is it a http post request or what is it?

So does this code just display the numbers or string that it gets at the end of this field -> ?text=

Better number handling & date handling

I've made a two other, sort of vaguely related changes in another branch:

  1. I have improved the handling of numerical formats so that the module is more likely to return a result. Specifically, if the user specifies format %d or some variation of %f (e.g., %.1f), the module will try to find a number in whatever value is grabbed from the REST API. For example, if "25 W" is returned, the updated module would find "25" using the parseFloat method, and return that as the result. It also allows using the parsed number to determine ranges.

This is particularly useful because OpenHAB now encourages users to specify units when using a number, so most of my "numbers" are actually strings containing digits and a string unit.

If the user prefers to stick with %s (the only viable option available with the current module), there will be no change in behavior.

  1. I have added a new option to specify that a returned value is expected to be a date (specifically, ISO 8601, but it may work with other date formats), and allows a user to customize how they want the date displayed using the Date().toLocaleString() method. It works in parallel to the "range" and "string" options already in the module. If the user, instead, specifies "dateOptions", the updated module will try to use the user-specified dateOptions to create a date string.

As with (1), sticking with %s will result in no changed behavior.

These seem really different, but they are both about handling different data types in a smarter manner. I was working on them both at the same time, so I only have a single branch with both changes. But if you like one but not the other, I can back one change out.

If you like either or both, let me know and I'll create another PR.

Second Module?

Is it possible to add a second MMM-Rest module in a config? I'm struggling to make it work, and I think it has to do with the fact that, in the second module, when you declare the output in the second instance as, say @1, it looks to the sections from the first instance for the data. But using @2 (one beyond the number in the first instance) results in null.

Update: I've gotten it to work (I think) by duplicating the ENTIRE mappings and sections sections in the second instance, and changing only the output. But this is obviously pretty cluttered and requires careful tracking to make sure they stay consistent. So if there's a more elegant solution, I'd love to know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.