TheThingSystem / steward

The Thing System is a set of software components and network protocols that aims to fix the Internet of Things. Our steward software is written in node.js making it both portable and easily extensible. It can run on your laptop, or fit onto a small single board computer like the Raspberry Pi.
http://thethingsystem.com
Other
346 stars 81 forks source link

add Telldus-live support #206

Closed mrose17 closed 10 years ago

mrose17 commented 10 years ago

@torkelsson - i'm going to make a quick sprint on this. do you think you can test it with your setup sometime next week. my guess is that we're talking about 30m of your time spread out over 2 or 3 nights, as we interate

thanks!

torkelsson commented 10 years ago

@mrose17, I think I should be able to the things, though I won't promise anything. Hopefully I will have time to upgrade to the latest release to night, so that I can start from that.

Thanks for you work adding Telldus support!

mrose17 commented 10 years ago

many thanks! my goal is to push something out within the next hour!

torkelsson commented 10 years ago

I will try to take a look at it tonight. Let's hope the kids will fail asleep early :-)

2014-04-28 7:43 GMT+02:00 mrose17 notifications@github.com:

many thanks! my goal is to push something out within the next hour!

— Reply to this email directly or view it on GitHubhttps://github.com/TheThingSystem/steward/issues/206#issuecomment-41524614 .

mrose17 commented 10 years ago

ok, initial support is in. here is what you want to do:

    cd steward
    git pull upstream master
    cd steward
    npm -l install

restart steward and then go to:

    http://steward.local:8887

click on the "gearbox" in the upper left-hand corner, scroll down to "Cloud Services", select "telldus live" in the drop down, enter the four magic values, and click on "Add Cloud Service"

assuming no errors, the steward should populate things directly.

what i do not know at this point is what the service returns when you do a setDeviceName or an onoffDevice or a dimDevice, so i've added some debug output to the console.

enjoy!

torkelsson commented 10 years ago

It is a "sensational" feeling seeing all the telldus thing showing in the steward. :-)

So far I have found the following issues:

Sometimes it does not turn on/off the lamps when changing the status in the steward. That may not be a problem with the steward but could as well be a problem with Telldus/Tellstick or that the lamp I tried with i a bit too far away from the Tellstick. I will do more tests later.

For on/off switches I have a level slider. Trying to change the level I get a "Missing Perform element" followed by a "Lost connection with steward. Refresh browser." when I do anything else.

After I have changed the status of a switch, it seems that i looses its status and name temporarily and it takes a while to get it back and a refresh or two of the browser.

I have to go into preferences and switch from metric to customary and back to metric for the temperature to show up in Celsius (might actually be that the temperature are shown in the wrong unit the first time you visit it).

The steward log is available at: https://www.torkel.se/misc/steward-2014-04-30.log

By the way, in Sweden we only have two holes in the wall, not three. Localized icons maybe? :-) The current icons looks a bit sad/scared/surprised :-)

the thing system the thing system 1 the thing system 2 the thing system 3

webchickbot commented 10 years ago

By the way, in Sweden we only have two holes in the wall, not three. Localized icons maybe? :-) The current icons looks a bit sad/scared/surprised :-)

:-O

mrose17 commented 10 years ago

great news!

i have pushed a new version to the github repo, so if you can do the usual:

    cd steward
    git pull upstream master
    cd steward
    npm -l install

and then restart the steward, you an try it out:

issues:

  1. not turning on/off - may be range related. i have updated the code to return errors properly.
  2. level slider for on/off - the slider is supposed to be disabled when you are using a non-dimmable outlet.

@ae9f - danny, the steward reports this:

    warning: [manage] wss 192.168.1.29 45931 /manage permanent=true, diagnostic=missing perform element, requestID=101, event=device performance

any ideas?

  1. temporary loss of state - should be fixed. if not, let me know. you an also click inside the title box and change the name. hopefully, i didn't botch that too badly!
  2. metric/customer - please submit this as a separate issue.
  3. three pronged outlet icon - i thought that since the mid-90's everyone, everywhere had to used "grounded" (nee "earthed") outlets. i expect that someone more clever than myself could come up with a two-prong solution that includes a ground, but it would likely involve a hyperspace phenomenon… (-;

do they really sell two prong outlets any more?

@webchickbot - becky, would it be possible to have a more stylized icon that didn't so closely mimic the US NEMA 5-15 plug?

thanks!

ae9f commented 10 years ago

Fixed level slider issue.

mrose17 commented 10 years ago

@ae9f - thanks!

torkelsson commented 10 years ago

Second test, with latest git-version (including commit 50c5218a4173d502d69e1cc2b5968760c1321bfc)

Most things seems to be working.

Log from tonight's testing is available at: https://www.torkel.se/misc/steward-2014-05-02.log

Anything else you want me to test?

In Sweden Type F, http://www.worldstandards.eu/electricity/plugs-and-sockets/f/ are the most common. Though type C still exists and you can nowdays find (and buy) ungrounded outlets shaped after the "Europlug". Maybe change the icon of the switches to an on/off icon (different icons for on and off?).

mrose17 commented 10 years ago

thanks! I am offline until Monday and plan to address the issues...

@ae9f - could you look at these two:

Changing level of a dimmable device, I get:

INVALID PARAMETERS {"INVALID":[],"REQUIRES":["NAME"]}

and it does NOT change the level.

and

Turning devices on/off: OK The slider is still there, but disabled. Would it be possible to "hide" it?

I know that we dim the slider, but maybe we shoulder something else?

@webchickbot - what do you think?

webchickbot commented 10 years ago

Apologies - I have been offline more than usual this week due to personal reasons. Here are two possibilities for a generic plug/outlet

plug

This one could potentially cover 2 and 3 prong outlets. plug 2

@ae9f Is there a way to change the code so Telldus devices show in my UI so I can take a look?

ae9f commented 10 years ago

@webchickbot - This device is of the switch type. There is an example earlier in this thread, and here is one from my steward (with a WeMo switch without level control). The slider is disabled.

safariscreensnapz049

webchickbot commented 10 years ago

Thanks - I updated the comment above with another icon possibility. I am thinking about the slider issue now ...

webchickbot commented 10 years ago

We could do something along the lines of the icons for the Tesla Model S ... If there is no slider we could do something like this:

Two states -- Left = On; Right = Off

screen shot 2014-05-02 at 11 27 40 am

This could also be integrated into the popover that has the slider as well ... probably wouldn't hurt to put a little polish on the UI elements that have been with us since Day One :-)

mrose17 commented 10 years ago

+1

webchickbot commented 10 years ago

Thanks! Let me know what you think of the icon ideas ... more than happy to get rid of the sad/scared/surprised element ... +1

webchickbot commented 10 years ago

Maybe change the icon of the switches to an on/off icon (different icons for on and off?).

@ae9f -- what do you think of this request for the switch? Would having an indicated on/off state in the index view for one of the icons be feasible?

ae9f commented 10 years ago

@webchickbot - The status color already indicates on/off state in the home screen, plus no other device class offers alternate state icons on the home page. Confusing, IMHO.

Re: two state buttons, above. When I look at the image, I can't tell which one is the active state. Is the switch on or off? If it's on, how would the off state look?

webchickbot commented 10 years ago

"ON" is the green on the left and "OFF" is the grayed out button - I could make it look more like the button is pressed down when it is on.

ae9f commented 10 years ago

Thing is, at a glance, the pair of images will always look like the switch is on because of the color. Perhaps if there were a red variant, it could indicate off so that the pair would either be green-gray (on) or gray-red (off).

And (just to be a bigger PITA), this button icon style in the real world is typically a single, push-on/push-off type of button.

ae9f commented 10 years ago

@mrose17 - should the level property of a level-equipped switch be adjusted with the 'set' or 'on' perform command? The d3 is currently using 'set'.

mrose17 commented 10 years ago

although"set" makes sense, the answer is "on"...

webchickbot commented 10 years ago

And (just to be a bigger PITA), this button icon style in the real world is typically a single, push-on/push-off type of button.

That's what it is meant to be ... I was just showing the two states.

Like this ... http://hongki.at/images/css3-on-off-button/demo/index2.html (which I just found)

ae9f commented 10 years ago

@mrose17 - Got it. It's like lighting brightness. Thanks.

@webchickbot - OK. Thought the two buttons were there to fill the space without a slider. Pls provide mockups for versions with and without the slider (unless you have other ideas for switches that don't have level adjustment).

ae9f commented 10 years ago

@torkelsson - Commit ae28ec3 hopefully takes care of the error when adjusting the level slider of a dimmable switch. I don't have a device here to test, so please give it a test. Potential UI changes are still in progress.

mrose17 commented 10 years ago

@torkelsson - grab the latest from github and let me know if this issue is resolved:

if not, please make available another file to look at the output.

with respect to this issue:

the steward refreshes every 5 minutes. there isn't a notification it can subscribe to, so that's what it does. we can adjust the timing, but that's about it… let me know what you think. thanks!

webchickbot commented 10 years ago

Pls provide mockups for versions with and without the slider (unless you have other ideas for switches that don't have level adjustment).

With slider on top - without slider on the bottom ... working towards polishing up the UI elements a bit ... sample

The thought is to show a "super simple popover" for no level adjustment things and once the user clicks to select a function within the small popover it would disappear after a predetermined amount of time (or if the user clicks anywhere outside of the popover window.)

Of course, losing the name of the thing eliminates the ability to rename the device ... what do you think of moving some of this functionality into the drilldown view (for instance we have "on/off", "adjust brightness", etc, on our lighting drilldown even though it leads to the same window).?

mocky

Having "super simple popovers" for these functions eliminates the need to create uniform designs for all popover types when there are not enough elements to justify it.

ae9f commented 10 years ago

@webchickbot - Using the on/off button as a slider knob is fraught with event programming peril (since HTML5 doesn't afford the luxury of gesture recognition of the kind in iOS, and we're using the d3 dragging facilities). It's possible to cancel the click event when the user drags, but if the user wiggles while clicking, we get a drag with no click...and user frustration at not being able to toggle on/off. We also have to think about other sliders where we have value readouts tagging along with the knob, where a 'giant' knob and legend would really crowd things.

  Of course, losing the name of the thing eliminates the 
  ability to rename the device ... what do you think of 
  moving some of this functionality into the drilldown 
  view (for instance we have "on/off", "adjust brightness", 
  etc, on our lighting drilldown even though it leads to the 
  same window).?

I've always regarded the items as a list of controllable properties, all encompassed within the popover. While it's possible to make the device name editable in the drilldown, the first-level drilldowns have traditionally been read-only. @mrose17?

 eliminates the need to create uniform designs for all 
 popover types

Am I old fashioned in promoting UI consistency within an app?

webchickbot commented 10 years ago

Am I old fashioned in promoting UI consistency within an app?

Nothing wrong with being consistent but sometimes in the most minimal of situations it is impossible to be rigidly consistent and aesthetically pleasing at the same time. Small context-sensitive windows based on actions are perfectly acceptable especially since we have plenty of real estate to tool around with in the drilldown for some of the functions we are displaying in the popover. It's good to think rev2 of the UI instead of working within established conventions.

I am thinking over the rest of your note and still meditating on an alternative icon for the generic plug.

mrose17 commented 10 years ago

@torkelsson - hi. here's the tl;dr for you: get the latest and see if

thanks!

torkelsson commented 10 years ago

@mrose17 - hi, another monday, another day with some time for testing:

Tested with "Ute: Garage/Dörr". The device was off when I started my testing. Testing with an empty log and the steward restarted before I started to test

  1. With the dimmable device off, and trying to change the level slider (by mouse down on the "knob") I get a "MISSING PERFORM ELEMENT", usually followed by a "Connection lost. Restart steward and refresh browser."
  2. There are still something fishy going on wrt dimmable devices. Sometimes they show up in the steward grey (is that when the status is unknown?), without any text for actions below the name. Clicking the name I get the popup in which I can change the state and level though.
  3. Most of the times the status of dimmable devices shows up with a Status on or off, instead of a Level , which I think it should?
  4. Sometimes turning the device on works, but the slider is at level 0, and it says that the Status is on, i.e it behaves more like an on/off switch. Sometimes the level is updated after a while. Probably at the next update from Telldus Live? The on/off switch is changed to off after the level is updated though.
  5. Sometimes it actually shows up as a dimmable device, showing the level, and both "turn off" and "adjust power" actions. I can move the slider, but nothing happens. If I turn the device off/on, the slider is moved back to the level it had before I changed it.

The behavior is really confusing, which makes it somewhat hard to test, because I don't know if what happens is a consequence of what I do, or because of features/bugs. Sorry for not giving more information :-)

Today's log is available at: https://www.torkel.se/misc/steward-2014-05-05.log

Would it be possible to manually change the icons (from a predefined set?). In my case some of the devices are connected to power outlets, in which case a generic power outlet icon makes perfect sense. Some of the devices though are connected behind the wall switches (for instance http://www.nexa.se/WMR-252-en.htm), and in that case an on/off switch icons makes more sense. There are no way to auto detect that though :-(

mrose17 commented 10 years ago

@torkelsson - hi. i think the big problem i have at the moment is that we don't have a way to test a dimmable thing here. let me see if i can figure out a few things"

  1. get the latest and see if you can repeat this and point me to the logs

2 & 3. when you see something fishy with a dimmer, go to https://steward.local:8888/console and find the dimmer and let me know what it says.

4 & 5. what i'd like you to do is issue the command and then cut-and-paste what the steward prints out, so i can correlate the behavior with what the steward is saying.

thanks!

ps: can you open up an issue on the manually change the icons question?

mrose17 commented 10 years ago

@ae9f - i was able to reproduce this when fiddling with the sound knob for a media device:

    error: [manage] wss 127.0.0.1 54518 /manage path=/api/v1/device/perform/58, requestID=114, perform=, parameter={}

both the perform and parameter fields are empty!

torkelsson commented 10 years ago
  1. Log at https://www.torkel.se/misc/steward-2014-05-07.log

The icons question filed as #215.

mrose17 commented 10 years ago

got it, thanks!

ae9f commented 10 years ago

I can't reproduce with my rocki.

@mrose17 - can you generate the error and then do the following in the browser console:

  1. Type newPerform
  2. Expand all the object properties
  3. Shoot me the results

Thanks.

torkelsson commented 10 years ago
  1. Turning on a dimmable device. After turning the device on I didn't touch it for 5 minutes (I opened the console in another window): turning on dimmable switch

The console says: /device/switch/nexa/dimmer off, on
name true status on, off, absent level percentage

Ute: Garage/Dörr device/18 on updated: 1m
level 0.00%

After 5 minutes:

dimmable switch 5 minutes later

The console change the information too: Ute: Garage/Dörr device/18 dim updated: 2m ago
level 50.00%

Log at: https://www.torkel.se/misc/steward-2014-05-07-2.log

mrose17 commented 10 years ago

it is not 100% reproducible, but this is what i see when it does happen:

newPerform < Object parameter: Object path: "/api/v1/device/perform/58" perform: "idle" requestID: "2" proto: Object defineGetter: function defineGetter() { defineSetter: function defineSetter() { lookupGetter: function lookupGetter() { lookupSetter: function lookupSetter() { constructor: function Object() { get proto: function () { hasOwnProperty: function hasOwnProperty() { isPrototypeOf: function isPrototypeOf() { propertyIsEnumerable: function propertyIsEnumerable() { set proto: function () { toLocaleString: function toLocaleString() { toString: function toString() { valueOf: function valueOf() {

torkelsson commented 10 years ago

After going back to the "overview" and touching the thing again I get:

second visit

(and nothing in the steward log)

torkelsson commented 10 years ago

If I Click on the name it looks like it actually knows the dim level and the console says that it is in state dim at 50%

changing state

mrose17 commented 10 years ago

i may have fixed the problem with the dimming levels. can you grab the latest and try again (this isn't including the UI issue)… thanks!

mrose17 commented 10 years ago

@torkelsson - any motion on this? just checking, thanks!

torkelsson commented 10 years ago

@mrose17, well it works a bit better, not perfect yet though and I think that there still are some bugs with dimmers. I'm not sure if it is UI bugs or not.

Afaict it is currently not possible to change the dimming level in the UI. You can change the level but it has no effect.

If I change the level outside of the Steward it is detected (after ~5 minutes).

If the dimmer is off, I can only turn it on, and then it is on at 100%, without any way to change it. I have to change it outside of the Steward for it to be detected as a dimmer. Would it be possible to "turn" of the dimmer without passing the dimming level and immediately read the status and dimming level back from Telldus live?

I have put a new log at: https://www.torkel.se/misc/steward-2014-05-12.log

mrose17 commented 10 years ago

thanks. i can change the polling from 5m to something else. what do you consider reasonable?

i got a 404 on the URL above. that's OK though. please give me two logs:

log 1 - boot the steward, turn the dimmer on without changing the level, then turn the dimmer off.

log 2 - boot the steward with the dimmer already on. now change the level.

thanks!

torkelsson commented 10 years ago

If possible I think it would be best to poll every time when entering a Telldus device and as often as possible, but at least every minute, or is that to often for the steward to handle it? Especially when running

  1. https://www.torkel.se/misc/steward-2014-05-13-1.log
  2. https://www.torkel.se/misc/steward-2014-05-13-2.log

And a couple of images from the second run:

1

After I restarted the Steward with the dimmer already turned on.

2

Before I "turned" the dimmer on from within the Steward. I.e the steward believed the dimmer was off.

3

After I turned it on. It is showing the correct level.

4

After I changed the level. No change on the lamp.

5

After ~5 minutes, i.e the status has been reread from Telldus live.

mrose17 commented 10 years ago

thanks for your patience. i may have fixed it. grab the latest.

the steward does the polling of the telldus live cloud, so i'll drop it to 60 seconds.

if the first issue isn't fixed, please do this:

  1. with an app turn the dimmer on and put it at 50%, then turn the dimmer off
  2. boot the steward, then using the HTML5/D3 client:
  3. what window do you see for the dimmer? what is the level set at?
  4. now turn the dimmer on without changing the status. what happens?
  5. now turn the dimmer off without changing the status. what happens?

then kill the steward and send the log. hopefully i'm logging the right stuff this time (-;

if the second issue isn't fixed, please send the images/narrative again, but with bigger images… they're a bit to small for me. thanks!

mrose17 commented 10 years ago

@ae9f - i figured out the bit where the steward complains about a missing perform element and then drops the connection.

if the HTML5/D3 client is in the drill-down page for a dimmer, as long as the dimmer is ON, you can move the slider and all is well. 1 however, if the dimmer is OFF and you attempt to move the slider, then the HTML5/D3 client sends this:

     path=/api/v1/device/perform/492, requestID=167, perform=, parameter={}

since an empty perform parameter is a protocol error. the steward returns this:

     permanent=true, diagnostic=missing perform element, requestID=167, event=device performance

and drops the connection. 2 so, the question is: what do we want the HTML5/D3 client to do when the user slides the dimmer and the dimmer is marked as OFF. my view is that the perform element should be 'on'. comments?

torkelsson commented 10 years ago

@mrose17 It's me that should thank you for working on this without having a device. I am really grateful. It looks like we are almost there for 1.

I can turn the dimmer on, but the level is at 0 and the status in the steward is not updated until the next poll (do you need to do an extra poll when changing state in the steward?). After the poll it looks like:

the thing system

And in the log I find:

telldus previous setting {"status":"off","level":"0"} dimmer previous setting {"status":"off","level":0} info: [switch] device/18 Ute: Garage/Dörr level=0 dimmer perform command {"perform":"on","level":0} telldus current setting {"status":"off","level":0} dimmer current setting {"status":"off","level":0}

If I then turn on the dimmer again, it immediately flips back to off and the steward actually says that it is off. In the log I find:

telldus previous setting {"status":"dim","level":"0"} dimmer previous setting {"status":"dim","level":0} info: [switch] device/18 Ute: Garage/Dörr level=0 dimmer perform command {"perform":"on","level":0} telldus current setting {"status":"off","level":0} dimmer current setting {"status":"off","level":0}

I tried to turn it on again:

telldus previous setting {"status":"dim","level":"0"} dimmer previous setting {"status":"dim","level":0} info: [switch] device/18 Ute: Garage/Dörr level=0 dimmer perform command {"perform":"on","level":0} telldus current setting {"status":"off","level":0} dimmer current setting {"status":"off","level":0}

On my third try I manage to turn it on and change the level before it flipped back to of in the steward. In the logs I found:

info: [switch] device/18 Ute: Garage/Dörr level=0

dimmer perform command {"perform":"on","level":0} telldus current setting {"status":"off","level":0} dimmer current setting {"status":"off","level":0} telldus previous setting {"status":"off","level":0} dimmer previous setting {"status":"off","level":0} info: [switch] device/18 Ute: Garage/Dörr level=9 dimmer perform command {"perform":"on","level":23} telldus current setting {"status":"on","level":23} dimmer current setting {"status":"on","level":9}

And the dimmer is on:

the thing system 3

until the next poll:

the thing system 2

Note that it says that the level is at 9% but it is off.

I can now turn it on and it stays at 9% until next poll, when it goes back to off, but with the level still at 9% and the lamp is actually still on.

I think the above also covers 2, an additional screenshot though which is after a restart of the steward, with the dimmer turned on:

the thing system 4

Note that there are no text below the name of the device.

Log available at: https://www.torkel.se/misc/steward-2014-05-14-1.log

torkelsson commented 10 years ago

@mrose17 Imho, if the dimmer is off and the user slides the dimmer, it should turn it on and set the level to what the users changes it to. I think that is the most natural and logical behavior. You can argue though that there should be no on/off switch on a dimmer, I'm not sure that is desired though.

I did some more testing, to verify what I should have known already (and probably did). In the Telldus case with Nexa dimmable device in the wall behind an on/off switch (yes you can use the button to set the dim level in Nexa device). The thing is that if you consider it being and on/off device it turns the lamp on and uses the level stored in the Nexa device. There is no way to get the level stored in the Nexa though :-(

On the other hand if you treat it as a dimmable device, you have to set the level every time you turn it on.

From Telldus live you can only get the current states: off, on (in which case it uses the level stored in the nexa device, i.e the level you set the last time you dimmed the device) and dim in which case you also can get a level. They have some kind of split personalities... :-(

Telldus are currently implementing device state history (see http://developer.telldus.com/blog/2014/05/12/device_state_history) that could eventually be used to restore the state of a dimmable device to the last used level, when it has matured...

Did I say that I am starting to dislike Telldus and Nexa? They are pretty cheap, but that's about it...