Open DavidNolander opened 6 years ago
yea but will just be a switch in homekit so no door actions there.. same with motion sensor..
would be nice if there could be more then just temp/hum sensor and on/off switches.. i know telldus don't support a motion sensor as other then on/off and then you via z-wave config set the level of detection that trigger that on/off.. but could a motion sensor be seen in homekit as as actually a motion sensor? i know there a homebridge adding that can do it with things like a pir sensor on a raspberry pi... @mifi ?
but i am loving how well this plugin is already working .. love from here ;-)
should be possible. https://github.com/KhaosT/HAP-NodeJS/blob/master/accessories/MotionSensor_accessory.js
you're saying telldus reports motion sensors the same way as on/off switches? if not I would need to know the json response of a motion sensor. even better a zwave sensor to test with :D
yea in telldus live they do.. if you need to change when a device changes stat then you do it by "edit the devices z-wave config"
{ "id": 9, "methods": 3, "name": "Motion Stuen", "state": 2, "statevalue": "", "type": "device" },
{ "id": 17, "methods": 0, "name": "Ford\u00f8r Sensor", "state": 2, "statevalue": "", "type": "device" },
{ "id": 20, "methods": 3, "name": "Bagd\u00f8r sensor", "state": 2, "statevalue": "", "type": "device" },
is there anything else you need ?
was looking in the code, i don't see any outlet service.. can that be added while we are at it ;-)..
"model": "outlet", or am i totally off? // just so that outlet would be shown as outlet's in homekit...
@DavidNolander have not found any window/door service in the homebridge software...
I implemented outlet and motion-sensor as well as improved models in readme.
You can test it with this:
npm i -g jchnlemon/homebridge-telldus#new-services
Then change your model to motion-sensor
or outlet
in config.json
For updated readme see: https://github.com/johnlemonse/homebridge-telldus/blob/new-services/README.md#device-models
When confirmed that it's working, i'll merge to master
hi, well the motion sensor does registret in homekit fine it seems, but when telldus say's there are motion ... homekit does not seem to see any triggering or alarm.. don't see anything in the logs either..
I have not checked the outlet model yet.. are not home until tomorrow again.. will check then.
Nov 26 13:21:04 raspberrypi homebridge[3816]: [2017-11-26 13:21:04] [Telldus Liv!e local] [Motion Stuen] Getting state for switch Motion Stuen [on]
i only get a trigger when i start the home app and it ask for data.. and then home app comes with a message.. so it seems that homebridge is not reading telldus and sending it to homekit if im not starting the home app(does not help just being ind the home app)... i have it on local API access.. would remote API do anything different ??
update: Outlet works..
update 2: found this: https://github.com/KhaosT/HAP-NodeJS/issues/382 https://github.com/KhaosT/HAP-NodeJS/issues/497
Using Remote API
I am guessing that the state of all switches are only fetched when the Home App starts?
Is it possible to push states to Homebridge when they change on the Telldus side?
From what I've seen in Home Assistant they can fetch state every 5 seconds, but it would be better if it was on change instead.
it's HAP-NodeJS https://github.com/KhaosT/HAP-NodeJS/blob/master/accessories/MotionSensor_accessory.js as homebridge-tellduq uses that does not support door-window sensor(at least i can't finde support in HAP-NodeJS releases).... homekit does.. i have an legato eve door sensor that works well..
2017-11-26 22:51 GMT+01:00 DavidNolander notifications@github.com:
Regarding the Door Sensor there is Characteristic Type for Door, number 12.
Can have 4 states in Homekit Close (0), Open (1), Closing (2), Opening (3), Stopped (4).
The Telldus Sensor in the API log has 2 states: {"ts":1511731836,"state":1,"stateValue":0,"origin":"Incoming signal","successStatus":0},{"ts":1511731836,"state":2," stateValue":0,"origin":"Incoming signal","successStatus":0}]}
1 = Open 2 = Closed
Don't know if its worth the hassle to add Door and just use those 2 states for Open, Close.
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/johnlemonse/homebridge-telldus/issues/61#issuecomment-347041326, or mute the thread https://github.com/notifications/unsubscribe-auth/AEfF4CG6_7FQu8dgUGe9mi2jt6-ML9BXks5s6d1fgaJpZM4QpjPI .
-- -Harry
State of all devices is fetched when showing devices on iOS. (Open Home app or slide up from below)
I guess we could continously poll telldus API every 5 sec and report this value to homebridge. I'm not sure how happy telldus would be about this though. At least we could do it for local API because then it just goes to your local device which does no harm. If there is a way to listen for events in telldus api it would be even better.
Ok.
How often can you do it local? Maybe an option to set intervall in the config? So default is on showing device.
On Home Assistant the interval can be set. Tried it there.
But even at 5 seconds it feels βunsmartβ so ifk it can be done more often on Local that would be great.
How often, i guess it depends on how many devices you have. but every 5 seconds doesn't sound too bad on local api. does home assistant use telldus live api or local api?
As I read up on telldus/api and HAP-NodeJS/homebridge.. and your code.. it seems it's telldus that does not inform the homebridge-telldus plugin that the motion sensor is triggered... could this be done in a lua script on the telldus znet lite device? that when a motion/door sensor is triggered it contacts homebridge-telldus via (lets say) json on a port?.. i have found other plugins/services that does this..
but your solution could work also, just not optimal ;-) (i know it's telldus that set the limit here).
On Home Assistant i used Live API.
5 seconds between opening a door and light turns on, thats like Forever :)
had a little talk with telldus..
There is a http plugin under development. Unfortunately there is a blocker for it to be released. If you are interested, read more here: https://github.com/scoder/lupa/issues/84 <<
To get the correct icon in HomeKit, was quite easy. I just added the following code to index.js:
{
model: 'contact-sensor',
definitions: [{ service: Service.ContactSensor, characteristics: [ Characteristic.ContactSensorState, Characteristic.StatusLowBattery ] }],
}
I don't think the StatusLowBattery is implemented since I can't see it in HomeKit. Then I simply added an entry to my config.json to set the device as a contact-sensor:
{
"local_id": 1,
"model": "contact-sensor",
"manufacturer": "Telldus",
"name": "AltandΓΆrr"
}
a 5 sec pulling would be nice, it seems that telldus is not gonna support local http events/actions even via lua some time soon.
the pulling could be used on door sensors and other things like alarms.. but should be a setting one would use on specific switches or other.. like "pull": true setting in config.json
Any update on this? This could solve my doorbell issue. It detects it as a motion-sensor, but does not update state on either timeout or inactivity.
If there is a way to listen for events in telldus api it would be even better.
@mifi : What about the Event manager in Telldus Live? It's possible to trigger a POST request on specified device event:
edit: ah....nevermind, going in circles here π
Yea but then we would need to listen on a public HTTP server for these http requests. I think this was discussed before but I didnt find an easy solution
I figured out a way to do this yesterday. Tried it during the day and it seem like a decent workaround at least.. Dunno if this is old news, so I'll try to give you the "quick start guide" first π€·π»ββοΈ
Goes without saying, but I'll say it anyway: Install Homebridge and Homebridge-Telldus. Use the Live! API for starters.
I don't know if it's relevant yet (I've used Homebridge for 2 days), but I run Homebridge with -D and -I (accessory control seems like an essential option).
Add one Door/Window magnet sensor in Telldus Live, if you haven't done so already.
Add any necessary entries to "unknown accessories" in the config.json. The contact sensor is the most important, of course. Example:
...
"unknown_accessories": [
{
"id": 5815808,
"model": "contact-sensor",
"manufacturer": "Nexa"
},
{
"id": 6845735,
"model": "contact-sensor",
"manufacturer": "Telldus"
}
]
...
4. Clear any leftover stale configuration cache from Homebridge and just check that it's up and running.
Now for the "interesting" part. Keep in mind that I'm fairly new to HB (but not to programming, debugging & coding in general though π ).
curl -X GET http://localhost:51826/accessories
If you have added some devices to Homebridge, you'll receive a looong JSON response with the complete accessory storage DB (minified, not like this guide. π€).
6.
So, what I did, was to copy the whole "accessories" JSON, and pasted it into "TextMate".
β+A and "Reformat JSON" (pretty-print, human readable, whatever...same thing), just to get a clear view of the data in it. I guess any decent JSON editor is sufficient.
π
"aid": 27,
"services": [
{
"iid": 1,
"type": "0000003E-0000-1000-8000-0026BB765291",
"characteristics": [
{
"iid": 2,
"type": "00000014-0000-1000-8000-0026BB765291",
"perms": [
"pw"
],
"format": "bool",
"description": "Identify"
},
{
"iid": 3,
"type": "00000020-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "Nexa",
"description": "Manufacturer"
},
{
"iid": 4,
"type": "00000021-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "contact-sensor",
"description": "Model"
},
{
"iid": 5,
"type": "00000023-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "Main Door",
"description": "Name"
},
{
"iid": 6,
"type": "00000030-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "xxx",
"description": "Serial Number"
},
{
"iid": 7,
"type": "00000052-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "1.0",
"description": "Firmware Revision"
}
],
"primary": false,
"hidden": false
},
{
"iid": 12,
"type": "00000080-0000-1000-8000-0026BB765291",
"characteristics": [
{
"iid": 13,
"type": "00000023-0000-1000-8000-0026BB765291",
"perms": [
"pr"
],
"format": "string",
"value": "Main Door",
"description": "Name"
},
{
π "iid": 14,
"type": "0000006A-0000-1000-8000-0026BB765291",
"perms": [
"pr",
"ev"
],
"format": "uint8",
π "value": 0,
"description": "Contact Sensor State",
"valid-values": [
0,
1
],
"maxValue": 1,
"minValue": 0
},
Be aware of the first and the last sections of the above JSON. These are however the values we need. (I marked them with π ):
"aid" (accessory ID) "iid" (Just yet another form of UUID)
and "value"
7. To trigger an update in the contact sensor (or its main characteristic value to be exact) , we can send a HTTP "PUT" request with the new values (I found this out randomly when I was about to give up π€«)
This request HAS to be sent with authentication headers as well as a "Content-Type:Application/json" header. You'll find the "authorization pin" by the QR code in HomeBridge (default HomeKit connect code)
Full example:
curl -X PUT http://localhost:51826/characteristics --header "Content-Type:Application/json" --header "authorization: 123-45-678" --data "{ \"characteristics\": [{ \"aid\": 27, \"iid\": 14, \"value\": "0"}] }"
response:
{"characteristics":[{"aid":27,"iid":14,"status":0}]}
A "0" value for "contact", of course means "No contact" == the door is open (and vice versa)
By the way, I just became aware of this one:
"iid": 15,
"type": "00000079-0000-1000-8000-0026BB765291",
"perms": [
"pr",
"ev"
],
"format": "uint8",
"value": 0,
"description": "Status Low Battery",
"valid-values": [
0,
1
],
"maxValue": 1,
"minValue": 0
}
Lo and behold. If I send
curl -X PUT http://localhost:51826/characteristics --header "Content-Type:Application/json" --header "authorization: 123-45-678" --data "{ \"characteristics\": [{ \"aid\": 27, \"iid\": 15, \"value\": "1"}] }"
...the battery status changes (= notification)!
So what I've done as a temporary thing, is to configure a simple python webserver that sends an update request to HomeKit/HomeBridge with the correct state value. In Telldus Live, I have an event configured to send a HTTP POST request to my python server with the state value as URL parameter, whenever the contact sensor senses anything.
Python then sends the "PUT" request instantly to Homebridge, and:
It works, kind of π my 5 cents, at least
My loose plan is to make a HB Plugin which acts kind of like a middle man between Telldus Live and HomeBridge-Telldus for sensor events (contact sensors, door bells, push buttons, motion detectors..). The ideal thing would be to have it integrated into the Homebridge-Telldus plugin rather than creating another plugin...seems like hassle for users.
Is that doable? @mifi
The Telldus Live trigger event could also be a Lua script locally, that's even smoother.π³
I just created a Tellstick plugin that (hopefully) will keep the contact sensors and their notifications in sync. I'm gonna try it out later and see if it's working the way I hope it does (!)
Basically it adds two helper functions to the local Telldus API, and it is intended to automatically push changes to HomeKit accessory characteristics on events regardless of origin app π₯³π
Hm. This actually worked great up until a recent Homebridge update. Now I get a "-70404" error whenever I do a "PUT" request to a contact sensor.
-70404 is the status code for "Cannot write to Read only property"
@mifi Any insights?
I think you just need to downgrade homebridge for now. I don't really have time or equipment to work on or test this now. But PR's are welcome!
I figured it out. Instead of sending a "PUT" request on characteric change, send:
curl -X GET <homebridge ip>:51826/characteristics?id=<aid>.<iid>
Example where "aid" for the accessory is 17 and "iid" for property "contact sensor state" is 10:
curl -X GET http://localhost:51826/characteristics?id=17.10
This should in fact be the default callback for all Telldus devices (accessories). It would eliminate the need for any extra scripting.
Just bought this:
http://telldus.com/produkt/magnetsensor-telldus-z-wave/
Should work as a switch with ON/OFF commands
Anyone got this to work in Homebridge?