Skip to content
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

Template reload causes sensors to trigger #266

Closed
FuzzyMistborn opened this issue Sep 17, 2020 · 5 comments
Closed

Template reload causes sensors to trigger #266

FuzzyMistborn opened this issue Sep 17, 2020 · 5 comments

Comments

@FuzzyMistborn
Copy link

Describe the bug

I have a few sensors that are template sensors. With the update to version .115, if I take advantage of the new "Reload Template Entities" service, it causes all the templates (sensors/binary sensors) to be reloaded, which in turn causes the state nodes I have in NR to trigger. I have them set to "output only on state change" and they still output. I'm not sure if there's a way to filter those out based on how the sensor is updated but it's slightly annoying as a few spit out a bunch of notification messages.

To Reproduce

Steps to reproduce the behavior:

  1. Have a sensor based on a template.
  2. Use that sensor in an Events: State node in NodeRed
  3. Go to configuration->Server Controls->Reload Template Entities in HomeAssistant
  4. See node output

Expected behavior

Ideally no output based solely on reloading the sensor.

Screenshots

Example Flow

[{"id":"70fa2021.44654","type":"server-state-changed","z":"9a7feaee.12c878","name":"Christmas Mode","server":"63517380.eb951c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.christmas_mode","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":380,"y":4160,"wires":[["658bab0.b6b6254"]]},{"id":"190db59b.f6aa9a","type":"api-call-service","z":"9a7feaee.12c878","name":"Christmas IB On/Off","server":"63517380.eb951c","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"turn_{{payload}}","entityId":"input_boolean.christmas","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":4180,"wires":[[]]},{"id":"766f2b33.7cb444","type":"change","z":"9a7feaee.12c878","name":"Set Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Tis the season!  The house is now in Holiday Mode.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":4100,"wires":[["189004dc.94e3eb"]]},{"id":"189004dc.94e3eb","type":"link out","z":"9a7feaee.12c878","name":"","links":["a2c80941.27ba"],"x":875,"y":4100,"wires":[]},{"id":"f1c2aca9.0f4f6","type":"change","z":"9a7feaee.12c878","name":"Set Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"The holiday season is now over.  Deactivating Holiday Mode.","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":4140,"wires":[["f1cca11f.4f083"]]},{"id":"f1cca11f.4f083","type":"link out","z":"9a7feaee.12c878","name":"","links":["a2c80941.27ba"],"x":875,"y":4140,"wires":[]},{"id":"351fd110.1c48ee","type":"switch","z":"9a7feaee.12c878","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":675,"y":4120,"wires":[["766f2b33.7cb444"],["f1c2aca9.0f4f6"]],"l":false},{"id":"658bab0.b6b6254","type":"api-current-state","z":"9a7feaee.12c878","name":"HASS Reboot","server":"63517380.eb951c","version":1,"outputs":2,"halt_if":"2","halt_if_type":"num","halt_if_compare":"gt","override_topic":false,"entity_id":"sensor.uptime_minutes","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":560,"y":4160,"wires":[["190db59b.f6aa9a","351fd110.1c48ee"],[]]},{"id":"63517380.eb951c","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Environment (please complete the following information):

  • Node Red Version: 1.13
  • Node.js Version: Not sure, I run via docker
  • NR Home Assistant Plugin Version: 0.25.1
  • Is Node Red running in Docker: Yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: Yes

Additional context

@zachowj
Copy link
Owner

zachowj commented Sep 18, 2020

I haven't testing .115 yet but my guess is if you look at the previous entity output, msg.data.old_state.state , it is something like unavailable or unknown. You can easily filter those out using a switch node after the event state node or changing to a trigger state node and filter inside of that.

image

@FuzzyMistborn
Copy link
Author

Actually the msg.data.old_state.state is reading as "null"

image

@zachowj
Copy link
Owner

zachowj commented Sep 18, 2020

Not sure what will break if I put a check to see if old_state is null. I'll have to look into that but in the interim, you can easily filter it out with a switch node.

image

[{"id":"e312da1a.239108","type":"server-state-changed","z":"ffbd7f06.4a014","name":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"test","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":138,"y":832,"wires":[["6ee10355.9464dc"]]},{"id":"6ee10355.9464dc","type":"switch","z":"ffbd7f06.4a014","name":"","property":"data.old_state","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":306,"y":832,"wires":[["f529974f.5c1dd8"]]},{"id":"f529974f.5c1dd8","type":"debug","z":"ffbd7f06.4a014","name":"do stuff","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":444,"y":832,"wires":[]}]

@FuzzyMistborn
Copy link
Author

Yep, figured that one out thanks. I'll leave this open in case you figure out a way to solve, but if you can't feel free to close.

@zachowj
Copy link
Owner

zachowj commented Oct 5, 2020

The above changes were reverted and I added some predefined ignore types to the event state node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants