Hi all,
I have created a flow to turn off my Ecobee if any of my windows or doors (Ring contact sensors) are opened. I found an example flow online to grab the current state and store it before turning off the Ecobee. To test it I am changing the switch conditions (==offoff or !=offoff) to trigger output 1 or output 2 of the switch, so the debug output always shows ‘offoff’ (in real testing, it would show onon, offon, or onoff).
When I trigger output 2, which would simulate an open window or door (ignore the offoff as it would be onoff, offon, or onon), I get the expect behavior of an array created storing the config of the Ecobee when it is on (see flow1 pic).
When I trigger output 1, which would simulate restoring the Ecobee to its previous state once a window or door is closed, I get an API error. It says, msg:string(78) “Call-service API error. Error Message: extra keys not allowed @ data[‘state’]” (see flow2 pic).
Picture devstate shows the developer state of climate.thermostat in my HA.
I cannot figure out what the problem would be as the ‘set_temperature’ service debug output contains all the variables of the array that is stored.
Can anyone point out where my error is, please?
Thanks,
Rick
Here is the exported flow:
[{"id":"d880fc48.dd42e","type":"tab","label":"Ecobee Control","disabled":false,"info":""},{"id":"6eab2e2c.b9916","type":"join","z":"d880fc48.dd42e","name":"Windows&Doors state","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":320,"y":320,"wires":[["4984654d.b87a7c","fba8f7eb.5aba28"]]},{"id":"4984654d.b87a7c","type":"debug","z":"d880fc48.dd42e","name":"Message output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":180,"y":220,"wires":[]},{"id":"1ea5934b.07efad","type":"trigger-state","z":"d880fc48.dd42e","name":"Windows state","server":"f616e80b.293518","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.windows","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":100,"y":300,"wires":[["6eab2e2c.b9916"],["6eab2e2c.b9916"]]},{"id":"f235ff40.56e94","type":"trigger-state","z":"d880fc48.dd42e","name":"Doors state","server":"f616e80b.293518","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"binary_sensor.doors","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":90,"y":360,"wires":[["6eab2e2c.b9916"],["6eab2e2c.b9916"]]},{"id":"f04a51b.91821b","type":"api-call-service","z":"d880fc48.dd42e","name":"Ecobee off","server":"f616e80b.293518","version":1,"debugenabled":false,"service_domain":"climate","service":"set_hvac_mode","entityId":"climate.thermostat","data":"{\"hvac_mode\":\"off\"}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":870,"y":480,"wires":[[]]},{"id":"fba8f7eb.5aba28","type":"switch","z":"d880fc48.dd42e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"offoff","vt":"str"},{"t":"neq","v":"offoff","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":320,"wires":[["54b30a85.39a3d4","a5a0930.ed3ae7"],["66c60ddf.8a2ed4","d0818904.bf8628"]]},{"id":"54b30a85.39a3d4","type":"debug","z":"d880fc48.dd42e","name":"Switch restore output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800,"y":280,"wires":[]},{"id":"66c60ddf.8a2ed4","type":"ha-get-entities","z":"d880fc48.dd42e","server":"f616e80b.293518","name":"Get Climate","rules":[{"property":"entity_id","logic":"is","value":"climate.thermostat","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":110,"y":560,"wires":[["4aad1e24.6f117"]]},{"id":"4aad1e24.6f117","type":"function","z":"d880fc48.dd42e","name":"transform data","func":"const payloads = [];\nconst payload = {};\npayload.domain = 'climate';\npayload.service = `set_temperature`;\npayload.data = {\n entity_id: msg.payload.entity_id,\n state: msg.payload.state,\n temperature: msg.payload.attributes.temperature,\n target_temp_low: msg.payload.attributes.min_temp,\n target_temp_high: msg.payload.attributes.max_temp\n};\n\n// create a blank message object with out new payload\nmsg = { payload: payload };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":560,"wires":[["e7da481b.6de7d8"]]},{"id":"f12c35ba.9d3488","type":"debug","z":"d880fc48.dd42e","name":"Climate state store","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":560,"wires":[]},{"id":"fe07c68b.0f5a08","type":"change","z":"d880fc48.dd42e","name":"","rules":[{"t":"set","p":"savedStates","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":560,"wires":[["f12c35ba.9d3488","f04a51b.91821b"]]},{"id":"a5a0930.ed3ae7","type":"change","z":"d880fc48.dd42e","name":"Get Saved States","rules":[{"t":"set","p":"payload","pt":"msg","to":"savedStates","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":120,"wires":[["6247c7cf.5cb858"]]},{"id":"8f420c5d.82373","type":"debug","z":"d880fc48.dd42e","name":"Climate state restored","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":860,"y":120,"wires":[]},{"id":"6247c7cf.5cb858","type":"split","z":"d880fc48.dd42e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":434,"y":120,"wires":[["719b7b39.cbf0e4","e66d815c.26bf4"]]},{"id":"719b7b39.cbf0e4","type":"api-call-service","z":"d880fc48.dd42e","name":"Ecobee Restored State","server":"f616e80b.293518","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":622,"y":120,"wires":[["8f420c5d.82373"]]},{"id":"e7da481b.6de7d8","type":"join","z":"d880fc48.dd42e","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":560,"wires":[["fe07c68b.0f5a08"]]},{"id":"d0818904.bf8628","type":"debug","z":"d880fc48.dd42e","name":"Switch save output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":360,"wires":[]},{"id":"e66d815c.26bf4","type":"debug","z":"d880fc48.dd42e","name":"Split output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":60,"wires":[]},{"id":"f616e80b.293518","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]