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

things: tellstick-net #73

Closed torkelsson closed 10 years ago

torkelsson commented 10 years ago

It would be great to have at least some basic support for tellstick-net (http://www.telldus.se/products/tellstick_net) in TTS. As the Tellstick Net only talks to the Telldus Live service as different solution is probably needed than for the other Tellsticks.

mrose17 commented 10 years ago

hi. sorry for the delay in getting back you.

here's what i know: the protocol for the tellstick-net is documented here: http://developer.telldus.se/doxygen/TellStickNet.html

it is a good start, but i need some more information to get things working. here are the details:

  1. gateway discovery: how do you find the tellstick-net(s) on the LAN?

they provide this by listening for a UDP broadcast on port 30303, and the response returns among other things the MAC address, which is great.

no issues with gateway discovery.

  1. peripheral discovery: how do you find out what things the tellstick-net can see?

there may be a message to support this, however, in looking at the open source tellstick-net firmware, it's not listed.

  1. peripheral control: once you know what the tellstick-net can see, which messages are applicable to each peripheral. my guess is that the starting point is here: http://developer.telldus.se/doxygen/TellStick.html
  2. peripheral monitoring: we can either register to receive events or we can poll to look for state changes. as with the peripheral discovery, i don't see any calls to enable registering for events.

with all that in mind, in http://developer.telldus.se/doxygen/index.html the telldus-core API is documented. here is what i need to know:

==> what packets should a program send in order to get the tellstick-net to perform:

tdGetNumberOfDevices
tdGetDeviceId / tdGetName
tdMethods / tdTurnOn / tdTurnOff / tdDim / tdBell
tdSensor / tdSensorValue

note that i am skipping registering for events because i don't think the tellstick-net architecture supports it.

so, here is my request of you: could you contact the folks at telldus and ask them the "what packets" question? i tried getting some help from them last week, but after four round-trips, i didn't get a solution. i suspect you may have better luck with them.

if you can get answers to these questions, then i think it is very easy for me to write a node-tellstick-net package and then have the steward use that.

thanks!

marshall

mrose17 commented 10 years ago

@btorkelsson - any luck getting answers? thanks!

torkelsson commented 10 years ago

@mrose17 - No, sorry I completely forgot it.

Though as a first step I think it would be better to consider the TellStickNet as a cloud service that you have to add manually, similar to nest, ecobee, netamoo, ... Even if that is really not in the spirit of TTS.

And then as second step try to discover them locally.

mrose17 commented 10 years ago

ok, that's fine. where can i find the specification telling me how to talk to their cloud service?

torkelsson commented 10 years ago

http://api.telldus.com/

mrose17 commented 10 years ago
       Q: what is the API for telldus.com
       A:             API.     telldus.com

(-;

mrose17 commented 10 years ago

ok. here we go! grab https://github.com/TheThingSystem/node-telldus-live

look at the README.md file and then get your 4 strings and put them into test.'s and then do this:

    % npm -l install
    % node test.js

and tell me what it does!

thanks,

/mtr

torkelsson commented 10 years ago

Wow. You are amazing and without access to it!

I'm not listing all devices, just a few of them. For every sensor/device I also got errors:

device #[object Object]: { error: 'Device "[object Object]" not found!' } sensor #[object Object]: { error: 'The sensor with id "[object Object]" does not exist' }

user: { firstname: 'Björn', lastname: 'Torkelsson', email: 'xxx@gmail.com', credits: 0, pro: -62169984000 } sensors: [ { id: '847133', name: 'Garaget - ute', lastUpdated: 1389912792, ignored: 0, client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '1154238', name: 'Väderstationen', lastUpdated: 1389912702, ignored: 0, client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 } ] devices: [ { id: '127878', name: 'Inne 10', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '144562', name: 'Inne: Vardagsrum', state: 0, statevalue: '0', methods: 0, type: 'group', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1, devices: '127874,127877,127875,414726' }, { id: '127952', name: 'Ute: Garage/Port', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 },

/Björn

mrose17 commented 10 years ago

thanks very much!

ok, grab the latest and let's see what it produces.

the problem that i have is that the API documentation doesn't explain things like whether it's a restful model, and assumes you can get the output (which isn't true if you don't have any devices).

once we see the latest output, then we can write a small test program to figure out a couple of other things.

at that point, we can then

torkelsson commented 10 years ago

As before, just a selection. I should have covered all different kinds I have though.

user: { firstname: 'Björn', lastname: 'Torkelsson', email: 'torkelsson@gmail.com', credits: 0, pro: -62169984000 }

sensors: [ { id: '847133', name: 'Garaget - ute', lastUpdated: 1389961562, ignored: 0, client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '1154238', name: 'Väderstationen', lastUpdated: 1389961040, ignored: 0, client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 } ]

devices: [ { id: '127878', name: 'Inne 10', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '144562', name: 'Inne: Vardagsrum', state: 0, statevalue: '0', methods: 0, type: 'group', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1, devices: '127874,127877,127875,414726' }, { id: '127875', name: 'Inne: Vardagsrum fönster', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '127953', name: 'Ute: Garage/Dörr', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '127952', name: 'Ute: Garage/Port', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '127951', name: 'Ute: Garage/Port+Pollare', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 }, { id: '127954', name: 'Ute: Stenparti', state: 0, statevalue: '0', methods: 0, type: 'device', client: '36887', clientName: 'Degernäs 165a', online: '1', editable: 1 } ]

sensor #0: { id: '847133', clientName: 'Degernäs 165a', name: 'Garaget - ute', lastUpdated: 1389961562, ignored: 0, editable: 1, data: [ { name: 'temp', value: '-13.0' } ], protocol: 'fineoffset', sensorId: '113', timezoneoffset: 3600 }

sensor #1: { id: '1154238', clientName: 'Degernäs 165a', name: 'Väderstationen', lastUpdated: 1389961040, ignored: 0, editable: 1, data: [ { name: 'temp', value: '-11.7' }, { name: 'humidity', value: '65' } ], protocol: 'oregon', sensorId: '13', timezoneoffset: 3600 }

device #0: { id: '127878', name: 'Inne 10', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'selflearning-switch:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: '10001' }, { name: 'unit', value: '1' } ] }

device #12: { id: '144562', name: 'Inne: Vardagsrum', state: '0', statevalue: '0', methods: '0', type: 'group', protocol: 'group', model: null, online: '1', editable: 1, parameter: [ { name: 'devices', value: '127874,127877,127875,414726' } ], devices: '127874,127877,127875,414726' }

device #13: { id: '127875', name: 'Inne: Vardagsrum fönster', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'codeswitch:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: 'A' }, { name: 'unit', value: '2' } ] }

device #15: { id: '127953', name: 'Ute: Garage/Dörr', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'selflearning-dimmer:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: '52002' }, { name: 'unit', value: '1' } ] }

device #17: { id: '127951', name: 'Ute: Garage/Port+Pollare', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'selflearning-switch:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: '50001' }, { name: 'unit', value: '1' } ] }

device #16: { id: '127952', name: 'Ute: Garage/Port', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'selflearning-dimmer:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: '51002' }, { name: 'unit', value: '1' } ] }

device #21: { id: '127954', name: 'Ute: Stenparti', state: '0', statevalue: '0', methods: '0', type: 'device', protocol: 'arctech', model: 'selflearning-switch:nexa', online: '1', editable: 1, parameter: [ { name: 'house', value: '53001' }, { name: 'unit', value: '1' } ] }

mrose17 commented 10 years ago

thanks. ok, what we have thus far is working. we now need to do two things:

  1. i need to verify what comes out of commands that change the state of a sensor/device. so, please get the latest and in test.js you'll see that it changes the name of two sensors and two devices from swedish to english. and if you run it a second time, it changes them back again. please run that and send me the output that relates to the calls for setDeviceName and setSensorName.
  2. what is also unclear about the API is whether it is "real" REST or "pseudo" REST. "real" REST uses things like GET, POST, PUT and DELETE, whilst "pseudo" REST uses GET and (often) POST. the other thing that is unclear is whether arguments have to go in the URI or in the body as content.

this is one of those things that just one real example would clear-up, but since all the examples (and the API explorer) don't actually go that deep, there's no way of knowing. i am going to ask their support people what the answer is. in the past, i have not had the best of luck (i.e., only bad luck) in getting an answer from them, so i may have to ask you to ask them and perhaps whatever is being lost in translation will be conveyed properly…

thanks!

torkelsson commented 10 years ago

The complete output from two runs:

https://www.torkel.se/misc/firstrun.txt https://www.torkel.se/misc/secondrun.txt

I you have any questions just shoot and I will try to figure it out myself and/or ask Telldus support. I may be a bit slow in responding though :-(

mrose17 commented 10 years ago

thanks. i got a reply from telldus and understand the easiest thing to make things work. your output aaas also very helpful.

ok, grab the latest and run test.js again … at the present time, i think i can recognize on/off switches and dimmable switches. this test will confirm that.

torkelsson commented 10 years ago

https://www.torkel.se/misc/tellstick-net.3.txt

I made some changes to test.js. a PR is sent!

mrose17 commented 10 years ago

thanks. i am moving this issue to the package itself; i have a revision to test.js for you to test; hopefully, the last!

https://github.com/TheThingSystem/node-telldus-live/issues/2