New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand json api for selector switch names #459

Closed
nayrnet opened this Issue Feb 10, 2016 · 10 comments

Comments

Projects
None yet
3 participants
@nayrnet
Contributor

nayrnet commented Feb 10, 2016

this is an enhancement request to extend the API to include level names, for example the MQTT API publishes the following JSON for a selector switch change that includes the switch name and level, but no indication of what friendly name that level has configured.

{"Battery":255,"RSSI":12,"dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","nvalue":2,"stype":"Selector Switch","svalue1":"40","switchType":"Selector","unit":1}

Request it to be extended to include an element with levelName, as such:

{"Battery":255,"RSSI":12,"dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","levelName":"Security Cameras","nvalue":2,"stype":"Selector Switch","svalue1":"40","switchType":"Selector","unit":1}

For example with my Pioneer AVR interface I include the level name in an array so I can have a friendly log name.. with the name exposed via JSON I could simply map that string to the input level and people can change the name alone through the UI.

I imagine custom interfaces using the JSON API would like to know what the level names are instead of a numerical value.

@gizmocuz

This comment has been minimized.

Show comment
Hide comment
@gizmocuz

gizmocuz Feb 10, 2016

Contributor

Your "Name" field is very unfriendly, how about making this "Friendly" ?

Contributor

gizmocuz commented Feb 10, 2016

Your "Name" field is very unfriendly, how about making this "Friendly" ?

@gaudryc

This comment has been minimized.

Show comment
Hide comment
@gaudryc

gaudryc Feb 13, 2016

Contributor

It seems I have missed something while implementing the Selector switch.
Can someone explain me how MQTT works ?

Contributor

gaudryc commented Feb 13, 2016

It seems I have missed something while implementing the Selector switch.
Can someone explain me how MQTT works ?

@nayrnet

This comment has been minimized.

Show comment
Hide comment
@nayrnet

nayrnet Feb 14, 2016

Contributor

MQTT uses the JSON API but instead of using HTTP requests for input and event scripts for return calls it uses a bi-directional PubSub broker so you device updates pushed out in realtime. Its really nice because you dont have to poll domoticz or maintain a bunch of events to keep external integrations in sync.

incoming commands look like: domoticz/in
{"command":"switchlight","idx":145, "switchcmd":"Set Level 40"}

and all updates come unsolicited like this: domoticz/out {"Battery":255,"RSSI":12,"dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","nvalue":2,"stype":"Selector Switch","svalue1":"40","switchType":"Selector","unit":1}

Its missing the Level Names being exposed like Lua has, so I cant do logic like
if (json.LevelName === 'Security Cameras') doSomeThing();

Currently I have to match json.svalue1 === '40' and then if I change selector order I have to reconfigure my MQTT software.. I maintain a separate array of level names externally simply so I can have clean logs like, Changed TV to Security Cameras, instead of: Changed TV to Level 40, Its not very consistent when I get the device name, dtype, stype, and switchType exposed.

@gaudryrc, some unrelated feedback, before the next stable release might reconsider the multiples of 10x for switch levels, a maximum of 10 selections is pretty limiting, I've already hit the limit twice, once for a FM Tuner and again for a PTZ Camera both with more than 10 presets.. I also dont get a Security Camera icon associated with the device however it works great for using Domoticz to make my PTZ do Pseudo AutoTracking, nearly perfect.. I dont need a 100 steps but a few dozen would cover just about everything.. I have 2 PTZ's on opposite corners of the house and they can see every door, window, and gate on my property.

thanks.

Contributor

nayrnet commented Feb 14, 2016

MQTT uses the JSON API but instead of using HTTP requests for input and event scripts for return calls it uses a bi-directional PubSub broker so you device updates pushed out in realtime. Its really nice because you dont have to poll domoticz or maintain a bunch of events to keep external integrations in sync.

incoming commands look like: domoticz/in
{"command":"switchlight","idx":145, "switchcmd":"Set Level 40"}

and all updates come unsolicited like this: domoticz/out {"Battery":255,"RSSI":12,"dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","nvalue":2,"stype":"Selector Switch","svalue1":"40","switchType":"Selector","unit":1}

Its missing the Level Names being exposed like Lua has, so I cant do logic like
if (json.LevelName === 'Security Cameras') doSomeThing();

Currently I have to match json.svalue1 === '40' and then if I change selector order I have to reconfigure my MQTT software.. I maintain a separate array of level names externally simply so I can have clean logs like, Changed TV to Security Cameras, instead of: Changed TV to Level 40, Its not very consistent when I get the device name, dtype, stype, and switchType exposed.

@gaudryrc, some unrelated feedback, before the next stable release might reconsider the multiples of 10x for switch levels, a maximum of 10 selections is pretty limiting, I've already hit the limit twice, once for a FM Tuner and again for a PTZ Camera both with more than 10 presets.. I also dont get a Security Camera icon associated with the device however it works great for using Domoticz to make my PTZ do Pseudo AutoTracking, nearly perfect.. I dont need a 100 steps but a few dozen would cover just about everything.. I have 2 PTZ's on opposite corners of the house and they can see every door, window, and gate on my property.

thanks.

@gaudryc

This comment has been minimized.

Show comment
Hide comment
@gaudryc

gaudryc Feb 14, 2016

Contributor

Do I have to send key names as lower case ?

Contributor

gaudryc commented Feb 14, 2016

Do I have to send key names as lower case ?

@nayrnet

This comment has been minimized.

Show comment
Hide comment
@nayrnet

nayrnet Feb 14, 2016

Contributor

I dont believe so, Battery, RSSI, and switchType are all mixed case.

Contributor

nayrnet commented Feb 14, 2016

I dont believe so, Battery, RSSI, and switchType are all mixed case.

gaudryc added a commit to gaudryc/domoticz that referenced this issue Feb 14, 2016

gizmocuz added a commit that referenced this issue Feb 15, 2016

Merge pull request #482 from gaudryc/send_device_options_on_MQTT_devi…
…ce_info_request

Fix missing Selector switch levels in MQTT device info response by returning all device options (#459)
@nayrnet

This comment has been minimized.

Show comment
Hide comment
@nayrnet

nayrnet Feb 15, 2016

Contributor

thanks for adding this, I am trying to test it but my build is failing.. I dont think its due to this.
see: 297b11e#commitcomment-16089333

Contributor

nayrnet commented Feb 15, 2016

thanks for adding this, I am trying to test it but my build is failing.. I dont think its due to this.
see: 297b11e#commitcomment-16089333

@gaudryc

This comment has been minimized.

Show comment
Hide comment
@gaudryc

gaudryc Feb 15, 2016

Contributor

@gizmocuz ,

Do you think we should send all options ?
Don't you think sending selector actions is not a security leak ?

Contributor

gaudryc commented Feb 15, 2016

@gizmocuz ,

Do you think we should send all options ?
Don't you think sending selector actions is not a security leak ?

@nayrnet

This comment has been minimized.

Show comment
Hide comment
@nayrnet

nayrnet Feb 15, 2016

Contributor

ok now I get output with all the LevelNames, I can work with this.. just have to parse through it.
{"Battery":255,"LevelActions":"|||||","LevelNames":"Off|TV|PS3|PS4|NVR|FM","LevelOffHidden":"false","RSSI":12,"SelectorStyle":"0","dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","nvalue":2,"stype":"Selector Switch","svalue1":"10","switchType":"Selector","unit":1}

I dont think the LevelActions would be useful for MQTT, if you believe they are a security concern you can omit that without issue.. My PTZ Selector's have some HTTP Auth passwords in them.

Contributor

nayrnet commented Feb 15, 2016

ok now I get output with all the LevelNames, I can work with this.. just have to parse through it.
{"Battery":255,"LevelActions":"|||||","LevelNames":"Off|TV|PS3|PS4|NVR|FM","LevelOffHidden":"false","RSSI":12,"SelectorStyle":"0","dtype":"Light/Switch","id":"000140E0","idx":145,"name":"TV","nvalue":2,"stype":"Selector Switch","svalue1":"10","switchType":"Selector","unit":1}

I dont think the LevelActions would be useful for MQTT, if you believe they are a security concern you can omit that without issue.. My PTZ Selector's have some HTTP Auth passwords in them.

@gizmocuz

This comment has been minimized.

Show comment
Hide comment
@gizmocuz

gizmocuz Feb 15, 2016

Contributor

That could be seen as a leak yes

Contributor

gizmocuz commented Feb 15, 2016

That could be seen as a leak yes

@gaudryc

This comment has been minimized.

Show comment
Hide comment
@gaudryc

gaudryc Feb 15, 2016

Contributor

Ok I will add a filter.
Thank you.

Contributor

gaudryc commented Feb 15, 2016

Ok I will add a filter.
Thank you.

@nayrnet nayrnet closed this Feb 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment