Closed houser42 closed 3 years ago
Maybe @crxporter has a better idea but I believe for accessories that doesn't work currently (aka switch is offline) we should use No Response so Home.app in iOS could show No Response red label.
As soon as 220V is down you should set No Response on devices that are using 220V
Ok, I see. Point taken. As I am running an older version of the NRCHKB node (0.9) I assume I will not have a way to set No Response? But if it is possible a pointer would be great. Many thanks.
Could you post me to an example on how/where to set that?
Since I've been called out on this, here I am!
I agree with Shaquu. No Response would be the way I would manage this. The devices would become "red" in HomeKit, Siri would respond "Sorry I can't access that device right now, please check the Home app", and no commands would be allowed in Home app.
I don't remember which version fixed the No Response, maybe 1.1? But the current 1.2 release is a good place to start, works great.
The NO_RESPONSE
setup is set by sending a value of "NO_RESPONSE"
to any of the characteristics supported by a device. For example if you are using a switch you can send {"On":"NO_RESPONSE"}
to the node. To clear it you send {"On":true}
(or false) to the node.
You can read a bit more about it in our readme and feel free to ask questions here.
Another thought: it is indeed possible but not tested to enable and disable accessories. You could try creating a flow with your 220v accessories then having nodered disable that flow. When 220v comes back online you can enable the flow again. I have not actually tested this approach but it might hide your 220v accessories from home app unless the flow is enabled. I have a hunch that your room assignments (and maybe automations) will be preserved as the accessories change from existent to non existent and back but you'll have to try it for yourself if you're interested.
Regarding my bonus idea: It does not work quite how I expected but it could still be ok for you depending on what you are hoping for.
It is indeed possible to enable/disable flows programmatically. @Shaquu will provide instructions for that.
Unfortunately when homekit devices are added or removed using this method, the room assignments and automations are NOT remembered.
This might or might not be ok for you. When devices are added back in, they are added to the room where the bridge is assigned. You could potentially have a bridge for each room then add and remove devices as you please by enabling and disabling flows.
Things that would work: "hey siri turn off the lights/switches/outlets in the living room" would turn off the items currently enabled in the room. "hey siri turn off all the lights" would turn off all current lights in the house. "hey siri turn off the chandelier" would work when there is a chandelier and would say "I don't find this device in your home" when there is no chandelier.
Things that would not work: Homekit automations. Room assignments which are different rooms from the bridge.
I will leave it for you, @houser42, to decide the approach that works best for you. We can continue discussing here until you've arrived at a setup you're happy with! Thanks!
Alright, Shaquu dumped it back on me to provide the flow.
Step 1 import this flow-
[{"id":"15d7457.fcac4bb","type":"subflow","name":"Change Flow Disabled","info":"","category":"","in":[{"x":40,"y":40,"wires":[{"id":"42613114.0e42c"}]}],"out":[{"x":860,"y":40,"wires":[{"id":"bc4c108.66f42f","port":0}]}],"env":[{"name":"flowId","type":"str","value":"PUT_FLOW_ID_HERE","ui":{"icon":"font-awesome/fa-id-card","label":{"en-US":"Flow ID"},"type":"input","opts":{"types":["str"]}}},{"name":"nodeRedUrl","type":"str","value":"http://localhost:1880/flow","ui":{"icon":"font-awesome/fa-chain-broken","label":{"en-US":"Node RED api url"},"type":"input","opts":{"types":["str"]}}}],"color":"#DDAA99"},{"id":"8920ad34.ac04a","type":"http request","z":"15d7457.fcac4bb","name":"Retrieve current flow state","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":200,"y":80,"wires":[["2c17ab5e.baf484","4ae06e4d.49bdf"]]},{"id":"bc4c108.66f42f","type":"http request","z":"15d7457.fcac4bb","name":"Update flow state","method":"PUT","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":80,"wires":[["50c71a03.281e54"]]},{"id":"2c17ab5e.baf484","type":"function","z":"15d7457.fcac4bb","name":"Change flow disabled","func":"switch (flow.get('action')) {\n case true:\n msg.payload.disabled = false\n break;\n case false:\n msg.payload.disabled = true\n break;\n default:\n msg.payload.disabled = !msg.payload.disabled\n break;\n}\n\n\nmsg.url = flow.get('url')\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":80,"wires":[["bc4c108.66f42f"]]},{"id":"4ae06e4d.49bdf","type":"debug","z":"15d7457.fcac4bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":150,"y":120,"wires":[]},{"id":"50c71a03.281e54","type":"debug","z":"15d7457.fcac4bb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":120,"wires":[]},{"id":"42613114.0e42c","type":"function","z":"15d7457.fcac4bb","name":"Prepare URL","func":"//action true-enable false-disable else toggle\nflow.set('action', msg.payload)\n\nreturn {\n url: flow.get('url')\n}","outputs":1,"noerr":0,"initialize":"flow.set('url', env.get('nodeRedUrl') + '/' + env.get('flowId'))","finalize":"","x":150,"y":40,"wires":[["8920ad34.ac04a"]]},{"id":"92fa3829.8bf878","type":"inject","z":"e0a1eb30.3f3ea","name":"enable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":350,"y":280,"wires":[["42ec474e.43e4c8"]]},{"id":"42ec474e.43e4c8","type":"subflow:15d7457.fcac4bb","z":"e0a1eb30.3f3ea","name":"","env":[{"name":"flowId","value":"8adfcdfd.a8bc9","type":"str"}],"x":600,"y":280,"wires":[[]]},{"id":"ba661f80.77b37","type":"inject","z":"e0a1eb30.3f3ea","name":"toggle (default)","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":240,"wires":[["42ec474e.43e4c8"]]},{"id":"9803b7c0.d164c8","type":"inject","z":"e0a1eb30.3f3ea","name":"disable","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":350,"y":320,"wires":[["42ec474e.43e4c8"]]}]
Step 2 get the ID of the flow you'd like to disable. Screenshot of where to find this on the nodered screen:
Step 3 copy that Flow ID into the flowId field in the subflow provided in step 1:
Step 4 set up homekit You will need to create at least one homekit item and bridge in a flow which is always enabled. Then you can create additional homekit services on the flow which is to be enabled and disabled - pointed to the same bridge. As you enable or disable the flow you will see the items appear or not appear in Home app.
Enjoy! Thanks for the interesting question!
Very interesting, will try it out asap!
It works, but when I try it the node red instance says: "The server is running a more recent set of flows. The changes include conflicts that must be resolved before they can be deployed" Also: Should the link be actual "http://localhost:1880/flow" or is that an example? If i enter the link in a browser I get "Cannot GET /flow"
..and finally, the NRCHKB node pops back into the same place it was entered, but adds it as a favourite. So as long as you add the node in the right place and if we could just have it skip the favourite setting it might actually work. Again, very, very interesting and promising.
The localhost:1880 is good on the pi - you can change it to the IP of the pi if you like.
When you hit it in the browser the error of "running more recent set of flows" is correct because your browser will be showing old flows - the subflow changes on the server but isn't updated on the browser, simply refresh your browser.
It would be cool to remember favorites. I'm not sure how to do that or if it's possible.
And I see Shaquu is responding also with the same answers.
Thanks guys. I get the part about ignoring the browser. About the favourite setting, it is as I am sure you know standard behaviour when adding a new accessory. Switching off the favourite and then hiding and unhiding resets it to on. But apart from that, it seems pretty perfect..
Just a preliminary report as I have tested this extensively and this works pretty great, as long as you get all your naming and room positioning right at time of adding the accessory.
Now if you gurus can figure out a way to set these two it will be perfect:
Another potential beauty with this, is that we can create dummies for native switches and put the native ones in another "system room" which in turn means any switch can be hidden/shown with this code.
So it might also potentially be used to hide switches that are only intended for admin use and so might add at least a basic level of security for switches that you don't want anyone to tap by mistake. Functionality that is sorely missing in HK IMHO. Ah well.. Very promising!
Sadly your last 2 requests are not possible from the device side as far as I know. There may be an app on iPhone which can connect to your HomeKit and have some more memory. I remember there was one a while ago that was claiming to back up a full homekit setup - that may be something to look at.
I of course don't know how often you switch grid power on/off so this might not be an option for you if it switches a lot. But if you switch it on for a week then off for a month - maybe it'd be ok.
Yes, I have and use that app to backup and restore entire HK homes. Very useful., So yes, I guess it is technically possible, at least from an app on an iPhone to manipulate those settings somewhat. 220 switches on and off based on sun, wind and needs so it goes off and on quite a lot. Hence my featurewish ;) But please keep this in the back of your minds if you come across a way in the future. Bookmarking the thread and thumbs crossed ;) Thanks again!
Hello!
A year later, just a message to say thanks again and that this still works pretty well! I have sorted all controls both in Node Red Dashboard and in Home Kit into one flow so they hide and show together. Very useful. A few comments as I know quite a bit more about Node Red a year later:
1. All settings in the node names and room settings must be set correctly before you add the nodes to Homekit, as they will be reset to those settings each time you enable and disable the flow.
2. When enabling and disabling a flow, the grouping with frames, backgrounds and formatting are lost. Only aesthetics and not a dealbreaker in any way but would be nice if it could be kept. Probably nothing to do with the NRCHKB but maybe worth a note for those wanting to try this.
It would be good if the favourite and status settings could be retained when enabled in HK, but probably also not a NRCHKB issue but a HomeKit issue/feature, as I recognise this behaviour from general Home Kit use.
The nodes that act on enabling and disabling the flow will also need to be de-activated while editing As I learnt that this causes some confusing states in node red. Maybe obvious..
Many thanks again. Has been very useful.
which person build this "Change Flow Disabled" node? YOU ARE MY HERO !!!
Hello, It would be great if there was a way to hide or change the look in some way of an offline NRCHKB node based on a state of another node or set conditions.
The reason I ask, is I have set up NRCHKB in an offgrid group of houses where about half of the nodes/switches are 12 volt and the others 220 volts. As there is no grid power, the 220 is off much of the time and it is confusing for users why some switches are not working at times and why switches are "updating" or show "no response".
Is it possible to display a custom message in the node/switch on the iPhone? Or even a way to completely hide all 220 switches when they are not available? Any other suggestions on some clever way to handle it would also be appreciated. Many thanks