Getting states of devices through voice command

With the Node-RED Alexa Home Skill Bridge it possible to create locks with the “Query lock state” feature checked and request their state.

So if you, for example, create a lock called “Windows”, you can ask alexa:

  • Are the windows opened?
  • Are the windows closed?
  • How are the windows?
  • etc etc

It even allows to ask " what’s the Windows?", so if you, for example, create a device called “Bathroom’s humidity”, she will eat that too, you’ll be able to ask “What’s the bathroom’s humidity?”, and she’ll understand the question.

Example with lights

[{"id":"42555e88.c533a","type":"alexa-home","z":"6cd0b2f8.4bb6fc","conf":"d27fbe6d.50ed4","device":"146768","acknoledge":true,"name":"Lights","topic":"","x":130,"y":960,"wires":[["fcd64f9a.351b6"]]},{"id":"6e346255.e0e61c","type":"delay","z":"6cd0b2f8.4bb6fc","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":960,"wires":[["da207139.aa269"]]},{"id":"da207139.aa269","type":"ha-get-entities","z":"6cd0b2f8.4bb6fc","server":"9405c3fe.d0a6c","name":"","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":470,"y":960,"wires":[["3f4e4b3.f7b1bb4"]]},{"id":"3f4e4b3.f7b1bb4","type":"switch","z":"6cd0b2f8.4bb6fc","name":"None?","property":"payload.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":610,"y":960,"wires":[["7cc03dd3.d46db4"],["a86471ab.3ccd"]]},{"id":"7cc03dd3.d46db4","type":"debug","z":"6cd0b2f8.4bb6fc","name":"TTS: all lights are off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":940,"wires":[]},{"id":"fcd64f9a.351b6","type":"switch","z":"6cd0b2f8.4bb6fc","name":"","property":"command","propertyType":"msg","rules":[{"t":"eq","v":"GetLockStateRequest","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":215,"y":960,"wires":[["6e346255.e0e61c"]],"l":false},{"id":"a86471ab.3ccd","type":"split","z":"6cd0b2f8.4bb6fc","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":750,"y":1000,"wires":[["a84aaf67.e8196"]]},{"id":"a84aaf67.e8196","type":"join","z":"6cd0b2f8.4bb6fc","name":"","mode":"custom","build":"string","property":"payload.attributes.friendly_name","propertyType":"msg","key":"topic","joiner":" ,","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":870,"y":1000,"wires":[["98464843.c6d978"]]},{"id":"98464843.c6d978","type":"debug","z":"6cd0b2f8.4bb6fc","name":"TTS: payload.attributes.friendly_name are on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1110,"y":1000,"wires":[]},{"id":"d27fbe6d.50ed4","type":"alexa-home-conf","username":"Obaldius"},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","addon":true}]

you can even create several devices like “Lights from the first floor” and “Lights from the second floor” and work the messages in Node Red. The advantage of doing it this way is you have flexibility with the questions you can make to Alexa and you needn’t create a routine for every imaginable question, the GetLockState command does the job.

Oh man, you are great. This solution work right out of the box for me. I was trying to work this out for the entire night. U just gave me the answer to it.

1 Like