Giter VIP home page Giter VIP logo

node-red-contrib-home-assistant-websocket's Introduction

node-red-contrib-home-assistant-websocket

Release Version Build Status License

BuyMeCoffee

Various nodes to assist in setting up automation using Node-RED communicating with Home Assistant.

Getting Started

Documentation can be found here.

Prerequisites

Have Node-RED installed and working, if you need to install Node-RED see here.

Installation

Install via Node-RED Manage Palette

node-red-contrib-home-assistant-websocket

Install via npm

$ cd ~/.node-red
$ npm install node-red-contrib-home-assistant-websocket
# then restart node-red

For Home Assistant add-on users:

The Community add-on ships with this node right out of the box.

Under the server node config just check the checkbox for I use the Home Assistant Add-on

The add-on can be found here: https://github.com/hassio-addons/addon-node-red#readme

Contribute

Contributors

List of all contributors

node-red-contrib-home-assistant-websocket's People

Contributors

12wrigja avatar albertnis avatar ayapejian avatar bodge-it avatar bonanitech avatar darchambault avatar davylandman avatar deadended avatar declankenny avatar dependabot-preview[bot] avatar dependabot[bot] avatar drjared88 avatar drogfild avatar edo78 avatar enjibby avatar fezvrasta avatar frenck avatar gambitc90 avatar github-actions[bot] avatar greenkeeper[bot] avatar jamesgol avatar jonathanadams avatar maxgyver87 avatar nigobo avatar oatybiscuit avatar primusnz avatar spartan-ii-117 avatar strikeir13 avatar thejta avatar zachowj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-red-contrib-home-assistant-websocket's Issues

Node Red flows stopped working after upgrade to HA 0.85.1

Describe the bug

When upgrading to the latest HA version node-red HA flows stopped working. After downgrading again it is working again.

To Reproduce

Upgrade HA from 0.83.2 to 0.85.1

Logs

Some loggin errors I get with new HA.

Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 31)
Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 32)
Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:53 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 33)
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 34)
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 35)
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: #
Jan 13 19:56:58 node-red Node-RED[31874]: (node:31874) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 36)

Environment

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.1
  • Is Node Red running in Docker: Sort of LXD Container

TimeoutOverflowWarning when starting node-red

Describe the bug
When starting node-red i'm getting: TimeoutOverflowWarning: 315360000000 does not fit into a 32-bit signed integer. in the logs.

To Reproduce
Steps to reproduce the behavior:
restart node-red or just press deploy and observe the logs.

Expected behavior
see the following in the log:

0|node-red | 13 Oct 17:18:41 - [info] [server:Home Assistant] New WebSocket http://localhost:8123
0|node-red | 13 Oct 17:18:41 - [debug] [server:Home Assistant] config server event listener connected
0|node-red | (node:20757) TimeoutOverflowWarning: 315360000000 does not fit into a 32-bit signed integer.
0|node-red | Timeout duration was set to 1.

Environment (please complete the following information):

  • Node Red Version: 0.18.4
  • NR Home Assistant Plugin Version: 0.1.1
  • Is Node Red running in Docker: no

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: I have
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): I did not, sorry.

Two hass instances problem

Describe the bug
When using multiple home-assistant instances, Entity IDs are not loaded from selected server, but from the first one. Even if I select different server in node properties and hit deploy, entities are still pulled from the wrong server.

To Reproduce
Steps to reproduce the behavior:

  1. add second hass server
  2. add new hass node
  3. select second hass server
  4. try to find entity from the second server (only from first one are populated).

Expected behavior
Etities from new server should show up in EntityID selector.

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.3.1
  • Is Node Red running in Docker: yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): yes

Events-node receives only state_changed events

Describe the bug
I'm new to NodeRed so there is still a chance that i'm doing something wrong.
I'm currently have a huge Hass.io instance with around 150 Xiaomi devices.
NodeRed addon is installed and i can see state_changed events, but other events are not being sent to NodeRed.
On the screenshot you can see a list of events that i have in a system:
screenshot 2019-02-03 at 22 11 30

But if i'm trying to listen for "xiaomi_aqara.click" in just doesn't work:
screenshot 2019-02-03 at 22 13 12

This is a screenshot of NodeRed after i tried to click my button multiple times:
screenshot 2019-02-03 at 22 14 10

From other side, if i will listen to all events (empty field), i will get state_changed events for my button:
screenshot 2019-02-03 at 22 15 23

To Reproduce
Steps to reproduce the behavior:

Note sure if there are any pre-conditions related to configuration of HA or NodeRed. Just install NodeRed from the scratch on Hass.io via addon manager and try to create events node that is listening to some event that is not "state_changed"

Expected behavior
I expect "xiaomi_aqara.click" event to be propagated from HA to NodeRed

Screenshots
Added above

Example Flow
n/a

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 1.2.5
  • Is Node Red running in Docker: hassio

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes

Additional context
I also opened the same issue on https://github.com/hassio-addons/addon-node-red here: hassio-addons/addon-node-red#126 but their answer was logical (to me). That plugin just wraps node-red plugins so it could be on a protocol level.

Device types with Alexa

I currently use one of the original Node Red plugins with Home Assistant and it seems it uses a Hue emulation to bring into Alexa? Will this be the same or can I have different types of devices?

Support converting (state) values

Is your feature request related to a problem? Please describe.
Currently when using for example the events: state node and the underlying entity is for example a binary_sensor or input_boolean you get an on or off value as string, and the same for sensors which have numbers as state which also get the value as string. This means later on in the message sequence you most likely need to handle this specifically. A switch needs == 'on' instead of is true, when using JSONata expressions you need to use $number() etc.

Describe the solution you'd like
I think it would be nice if the Events: state node etc have a dropdown from which you can select the payload type you like to use. So the default can then still be string which contains for example the on/off etc, but that you could also select Boolean and you get true/false as payload value. An extra option would then be to have a Number choice which converts numbers and so on.
In case a conversion fails (because of for example selecting the wrong type) I think no message should be send. The same as when using a switch node with a JSONata expression, which also is neither true nor otherwise when for example doing "1" < 2. If this case should result an in error which can be handled using a catch node is up for debate (switch + JSONata don't seem to do this).

Describe alternatives you've considered
As described above you can work around it by using == 'on', $number() etc. But I think that converting the values beforehand would reduce the chance of bugs, and speaking for myself when I started using this module (or actually the REST version) I expected the values to be already of the "correct" type, so binary sensors and input booleans being true or false, other (numeric) sensors containing a number, etc.

Note: if this is a desired feature I most likely will be able to make the necessary changes myself, but if this feature isn't accepted, or some other direction is requested, I'm of course not going to spend my time on making the changes first.

Make merging optional in Service Call node

Hello!

Is your feature request related to a problem? Please describe.
I feel frustrated when I want to chain Service Call nodes together and have to place a Change node (Delete: msg.payload) between them because what I assume is the merge resolution.

Describe the solution you'd like
This may be simply be because I rarely use merging in the Service Call node, but I'd love to have a tickbox where we could make this optional. It would save me copy/pasting a load of Change nodes!

Describe alternatives you've considered
Inserting a Change node to delete the msg.payload after each Service Call node.

Additional context
None.

Thanks, I love this project :)

Race condition on state_changed nodes and the global homeAssistant.states object

Describe the bug

When an state_changed node triggers a change for an input_boolean, there is a race condition with the global.get('homeassistant').homeAssistant.states object being updated.

When the state change is triggered, the payload is correct, but the states object is not updated.

I doubt this is specific for input_booleans, but that is the only one I've verified the problem.

To Reproduce

Here is a typical function node I am using:

let ha = global.get('homeassistant').homeAssistant
let s = function(v) {
    return ha.states[v].state
}

if (s('input_select.mode') === 'Away') {

    msg.payload = 'scene.0etg_away'

} else if ( s('input_select.mode') === 'Night') {
    
    msg.payload = 'scene.0etg_off'

} else if ( s('input_boolean.floor0') === 'off') {
    
    msg.payload = 'scene.0etg_off'

} else if ( s('input_select.sceneoverride') === 'Flood') {
    
    msg.payload = 'scene.0etg_flood'

} else if ( s('input_boolean.active_kjellerstua') === 'on') {
    
    msg.payload = 'scene.0etg_dim'

} else if ( s('input_select.timeperiod') === 'earlyMorning') {
    
    msg.payload = 'scene.0etg_dim'

} else if ( s('input_select.timeperiod') === 'morning') {
    
    msg.payload = 'scene.0etg_normal'

} else if ( s('input_select.timeperiod') === 'day') {
    
    msg.payload = 'scene.0etg_normal'

} else if ( s('input_select.timeperiod') === 'leggeTid') {
    
    msg.payload = 'scene.0etg_soft'

} else if ( s('input_select.timeperiod') === 'evening') {
    
    msg.payload = 'scene.0etg_dim'

} else if ( s('input_select.timeperiod') === 'lateEvening') {
    
    msg.payload = 'scene.0etg_dim'

} else {
    
    msg.payload = 'scene.0etg_normal'
    
}

return msg

A changed input_boolean.floor0 will cause the function node above to be executed, but it will be based upon the old value.

As a result, my outdoor lights turn off in the evening, and the lights in my bathroom turns off when I enter. The background music on the bathroom becomes louder when I open the door, and quiter when I close the door. The lights above the TV dims down when I pause a movie, and floods the room when I hit play.

Environment (please complete the following information):

I'm pretty sure the problem was introduced at the same time I updated to version 0.5.1. The problem was not present in 0.5.0.

  • I've installed Node red using hass.io, the hass.io addon version 1.2.3.
  • Node Red Version: 0.19.5

Current State Node (Halt)

Hi!

I am trying to halt a flow by using the current state node, but it is not working how I need it.

So, I am looking at a binary sensor. When this turns ON, I want to make sure a door is closed. If it is closed, I want to send the binary sensor state, not the door state.
Is this possible? If yes, want am I doing wrong?

Thank you so much for a great project!

[{"id":"f9b7c846.68fcf","type":"tab","label":"Garage Example","disabled":true,"info":""},{"id":"4b06902.67c1f7","type":"server-state-changed","z":"f9b7c846.68fcf","name":"Garage Detection","server":"9e03419b.3df268","entityidfilter":"binary_sensor.motion_sensor_158d0001e574ae","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"error","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":130,"y":100,"wires":[["ea672ac7.d28e48"],[]]},{"id":"ea672ac7.d28e48","type":"switch","z":"f9b7c846.68fcf","name":"On or Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":320,"y":100,"wires":[["65c5679e.51744"],["661f1258.e73bb4"]]},{"id":"65c5679e.51744","type":"api-current-state","z":"f9b7c846.68fcf","name":"Main Garage Door","server":"9e03419b.3df268","outputs":2,"halt_if":"on ","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.main_garage_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":530,"y":80,"wires":[["ddd3bcbc.d18bf","661f1258.e73bb4"],[]]},{"id":"ddd3bcbc.d18bf","type":"api-call-service","z":"f9b7c846.68fcf","name":"Garage Lights","server":"9e03419b.3df268","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.switch_10\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":980,"y":80,"wires":[[]]},{"id":"661f1258.e73bb4","type":"trigger","z":"f9b7c846.68fcf","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"1","extend":true,"units":"min","reset":"on","bytopic":"all","name":"Trigger 10min","x":760,"y":160,"wires":[["e8f70502.1852a"]]},{"id":"e8f70502.1852a","type":"api-call-service","z":"f9b7c846.68fcf","name":"Garage Lights","server":"9e03419b.3df268","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"switch.switch_10\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":980,"y":160,"wires":[[]]},{"id":"9e03419b.3df268","type":"server","z":"","name":"HASS","legacy":true,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

Mustache template in call service node is not able to render {{global.name}}

Description
I have an alarm flow that uses a global value {{global.alarm_trigger}} to hold the friendly name of the sensor that has triggered. This is set based on an event change from a sensor and the flow stores the global value checks the alarm is armed and goes on to trigger the alarm.

The alarm triggered flow then sends a pushover message via a call service node to tell the user that the sensor that triggered the alarm using the global value. If I use a template node to construct the message everything works. If I embed the moustache template in the call service node with render templates enabled the {{global.alarm_trigger}} does not get rendered

To Reproduce
Steps to reproduce the behavior:

  1. set global.alarm_trigger in flow to friendly name ie. "Garage Motion"
  2. create call service node for pushover with moustache template:
{
   "data":{
      "title": "HomeAssistant: Security",
      "message": "Alarm has been activated. Detected {{global.alarm_trigger}}."
    }
}
  1. tick box for render templates
  2. resulting message ends "Detected ."

Expected behavior
{{global.alarm_trigger}} should render to "Garage Motion" not null

Screenshots
image

Example Flow: working (move the template to call service to see issue)
[{"id":"bbf291c4.cd13d8","type":"server-state-changed","z":"1c78f795.492d28","name":"All PIRs","server":"c67e9b43.8d8f98","entityidfilter":"^binary_sensor\\.\\w+_[pir|door]_\\w+","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"","halt_if_compare":"is","outputs":2,"x":110,"y":640,"wires":[["3b9c2e2e.92b2a2","d041b019.b2e59"],[]]},{"id":"3b9c2e2e.92b2a2","type":"change","z":"1c78f795.492d28","name":"","rules":[{"t":"set","p":"alarm_trigger","pt":"global","to":"data.new_state.attributes.friendly_name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":640,"wires":[["d041b019.b2e59","ba5d235b.eca0f8"]]},{"id":"d041b019.b2e59","type":"debug","z":"1c78f795.492d28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","x":670,"y":460,"wires":[]},{"id":"ba5d235b.eca0f8","type":"switch","z":"1c78f795.492d28","name":"","property":"topic","propertyType":"msg","rules":[{"t":"else"},{"t":"cont","v":"garage_pir","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":640,"wires":[["f05ba280.90cc5"],["54e4f18a.a132a8"]]},{"id":"f05ba280.90cc5","type":"api-current-state","z":"1c78f795.492d28","name":"Get Alarm State","server":"c67e9b43.8d8f98","halt_if":"disarmed","override_topic":true,"override_payload":true,"entity_id":"alarm_control_panel.ha_alarm","outputs":1,"x":780,"y":620,"wires":[["5f6a0759.bdcff8"]]},{"id":"54e4f18a.a132a8","type":"template","z":"1c78f795.492d28","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"data\":{\n \"title\": \"HomeAssistant: Security\",\n \"message\": \"Alarm has been activated. Detected {{global.alarm_trigger}}.\"\n }\n}\n","output":"json","x":700,"y":720,"wires":[["971ec9ff.e69248","d041b019.b2e59"]]},{"id":"77b9628f.e82404","type":"inject","z":"1c78f795.492d28","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":720,"wires":[["54e4f18a.a132a8"]]},{"id":"971ec9ff.e69248","type":"api-call-service","z":"1c78f795.492d28","name":"Pushover Adrian (Triggered)","server":"c67e9b43.8d8f98","service_domain":"notify","service":"po_adrian","data":"{}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":960,"y":720,"wires":[["d041b019.b2e59"]]},{"id":"5f6a0759.bdcff8","type":"switch","z":"1c78f795.492d28","name":"Armed ?","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"^armed_","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":1,"x":1000,"y":620,"wires":[["e89d4a92.3945d8","d041b019.b2e59"]]},{"id":"e89d4a92.3945d8","type":"api-call-service","z":"1c78f795.492d28","name":"Trigger Alarm","server":"c67e9b43.8d8f98","service_domain":"alarm_control_panel","service":"alarm_trigger","data":"{\"entity_id\":\"alarm_control_panel.ha_alarm\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":1190,"y":620,"wires":[["d041b019.b2e59"]]},{"id":"c67e9b43.8d8f98","type":"server","z":"","name":"HomeAssistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true}]
Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.1
  • Is Node Red running in Docker: yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes

Additional context
Think the original moustache template handling did not work with {{flow.name}} or {{global.name}} and had to be changed to add this support

halt if, state type boolean

If I select the State Type to be boolean, I can't get the half if logic to work. I think it compares a string value with the typecasted boolean value and thereby always return the same result.

Suggestion would be to add "is true" and "is false" to halt if state select field. Like the switch node.

[{"id":"7be3df3c.b09a08","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"c8a604e5.e9b1b","type":"server-state-changed","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","entityidfilter":"input_boolean.andreas","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"true","halt_if_type":"","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":329.14337158203125,"y":198.9227752685547,"wires":[["18dd1e56.dc1ca2"],["58e5b5e.8985ccc"]]},{"id":"18dd1e56.dc1ca2","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":704.1506652832031,"y":138.29779052734375,"wires":[]},{"id":"58e5b5e.8985ccc","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":702.8345947265625,"y":231.8235321044922,"wires":[]},{"id":"e9d78177.105cf8","type":"server-state-changed","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","entityidfilter":"input_boolean.andreas","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"on","halt_if_type":"","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":328.8345642089844,"y":378.82354736328125,"wires":[["bea7464a.45fdf8"],["7b2870b4.e73ab8"]]},{"id":"bea7464a.45fdf8","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":703.8418579101562,"y":318.1985626220703,"wires":[]},{"id":"7b2870b4.e73ab8","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":702.5257873535156,"y":411.72430419921875,"wires":[]},{"id":"6887f056.ec2228","type":"server-state-changed","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","entityidfilter":"input_boolean.andreas","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"false","halt_if_type":"","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":334.8345642089844,"y":571.8235473632812,"wires":[["9c8d60cc.855708"],["812734ab.3aaeb"]]},{"id":"9c8d60cc.855708","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":709.8418579101562,"y":511.1985626220703,"wires":[]},{"id":"812734ab.3aaeb","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":708.5257873535156,"y":604.7243041992188,"wires":[]},{"id":"739b33b3.b506e4","type":"server-state-changed","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","entityidfilter":"input_boolean.andreas","entityidfiltertype":"exact","outputinitially":true,"state_type":"habool","haltifstate":"off","halt_if_type":"","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"x":334.5257568359375,"y":751.7243194580078,"wires":[["9e2edd95.103df8"],["3698a4e.3ce8adc"]]},{"id":"9e2edd95.103df8","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":709.5330505371094,"y":691.0993347167969,"wires":[]},{"id":"3698a4e.3ce8adc","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":708.2169799804688,"y":784.6250762939453,"wires":[]},{"id":"e9d8a6bb.da13","type":"api-current-state","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","outputs":2,"halt_if":"true","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.andreas","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","x":1182.1544227600098,"y":192.63232421875,"wires":[["441cb96f.6d55d8"],["389c05bd.b09652"]]},{"id":"441cb96f.6d55d8","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1495.8345985412598,"y":140.8235321044922,"wires":[]},{"id":"389c05bd.b09652","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1494.5185279846191,"y":234.34927368164062,"wires":[]},{"id":"1450246c.cf8234","type":"inject","z":"7be3df3c.b09a08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":929.1543922424316,"y":190.46322631835938,"wires":[["e9d8a6bb.da13"]]},{"id":"52192d69.b657f4","type":"inject","z":"7be3df3c.b09a08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":933.8345336914062,"y":373.82354736328125,"wires":[["a6a1c2c6.0b8ac8"]]},{"id":"a6a1c2c6.0b8ac8","type":"api-current-state","z":"7be3df3c.b09a08","name":"","server":"b3647e80.a78bd","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.andreas","state_type":"habool","state_location":"payload","override_payload":"msg","entity_location":"","override_data":"none","x":1186.8345642089844,"y":375.9926452636719,"wires":[["a03a00e2.152a2"],["5dd54ad8.ec6024"]]},{"id":"a03a00e2.152a2","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1500.5147399902344,"y":324.18385314941406,"wires":[]},{"id":"5dd54ad8.ec6024","type":"debug","z":"7be3df3c.b09a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1499.1986694335938,"y":417.7095947265625,"wires":[]},{"id":"b3647e80.a78bd","type":"server","z":"","name":"HASS","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

Cannot GET `/homeassistant//services`

Describe the bug

screen shot 2018-12-09 at 22 58 11

Solving issue #49 introduced a new issue, see screenshot above.

Caused by the following lines:

$.get(`homeassistant/${node.server}/entities`)

return $.get(`homeassistant/${node.server}/services`)

When there is no specific server node, the extra slash makes it an invalid URL for Hass.io.
The extra slash should only be included in case node.server actually has a value.

To Reproduce
Steps to reproduce the behavior:

  1. Add call service node

Expected behavior
Working stuff ;)

Screenshots
See opening post.

Example Flow
N/A

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.4.1
  • Is Node Red running in Docker: yes (Hass.io)

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: Yes, see references.
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): Yes.

Additional context
N/A.

How to use trigger:state object

Hi,

I'm struggling to turn nodes in HA on or off with the trigger: state object. According to the input documentation I should be able to change the state of an node when the "incoming payload or message is a string and equal to 'enable' or 'disable'". For this I've created the following setup:
image
The enable function contains the following:

msg.payload = "enable";
return msg;

the disable function is the same, but then with "disable" in the payload.

Unfortunately, I do not manage to turn the HA node on or off.

How can I utilise this object to interact with HA nodes?

Cheers,
Ian

Duplicate output after update

Describe the bug
Duplicate output after upgrading to v0.5.1.
If I open any "current state" node the output is then duplicated.

Screenshots

image

Example Flow
[{"id":"2e6bb5d8.39a85a","type":"api-current-state","z":"30559228.a0d01e","name":"Note","server":"a1153b55.2eb9d8","halt_if":"off","halt_if_type":"","halt_if_compare":"is","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"switch.note","state_type":"str","outputs":2,"x":330,"y":1560,"wires":[["ea54e7bf.87d148"],[]]},{"id":"a1153b55.2eb9d8","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

Environment

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.1
  • Is Node Red running in Docker: no

Other:

  • Have you searched previous issues for duplicates?: yes

Entity IDs as-you-type suggestion window not working

Describe the bug
When entering an Entity ID on any HA node, it usually pops-up suggestions of entities as you type. It's not working

To Reproduce
Steps to reproduce the behavior:

  1. Drag an open an events: state node
  2. On the Entity ID field, start typing 'switch'
  3. A window showing entity ids that start with 'switch' should pop-up under the Entity ID field

Expected behavior
A window showing matching entity ids should pop-up under the Entity ID field as you type

Environment (please complete the following information):

  • Node Red Version: 0.19.4
  • NR Home Assistant Plugin Version: 0.7.0
  • node-red-contrib-home-assistant-websocket Version: 0.0.4
  • Is Node Red running in Docker: yes

Can't find instructions on how to get long lived token without hassio

Describe the bug
I'd like to get set up on a native node-red/homeassistant install (not hassio), but I don't see any instructions for getting the long lived token.

To Reproduce

  1. Install node red and home assistant direct to ubuntu server
  2. Add home-assistant-websocket to the pallet
  3. try to configure it, discover you have no idea how to get the token.

Expected behavior
There are instructions for getting a long lived token.

Environment (please complete the following information):

  • Node Red Version: [e.g. 0.19.5] 0.19.5
  • NR Home Assistant Plugin Version: [e.g. 0.5.0] 0.6.1
  • Is Node Red running in Docker: [e.g. yes/no/hassio] NO

Other (please complete the following information):

  • Have you searched previous issues for duplicates?:
    yes

Error fetching node id's when editing node

Describe the bug
When editing a node, a error is displayed:
TypeError: Cannot read property 'getEntities' of undefined
at ConfigServerNode.getEntities (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/nodes/config-server/config-server.js:9:18)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at /usr/lib/node_modules/node-red/red/api/auth/index.js:63:13
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:335:12)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:275:10)
at /usr/lib/node_modules/node-red/node_modules/express/lib/application.js:233:9
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:635:15
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:260:14)
at expressInit (/usr/lib/node_modules/node-red/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)

And consequently autofill on entity id is not working.

To Reproduce
Steps to reproduce the behavior:
Open a node containing a entity id field such as current state
Error will be displayed in the notification area of node-red and auto fill will not work.

Expected behavior
When editing a node that utilizes entity id, the entity id field should auto populate as you type and an error should not be displayed

Screenshots
image

Example Flow
[{"id":"142aede4.c4e932","type":"api-current-state","z":"b9288163.54493","name":"test","server":"dccd1a65.3b5848","halt_if":"","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"sun.sun","x":470,"y":700,"wires":[[]]},{"id":"30bafbbe.785ce4","type":"inject","z":"b9288163.54493","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":700,"wires":[["142aede4.c4e932"]]},{"id":"dccd1a65.3b5848","type":"server","z":"","name":"HA01","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true}]

Environment (please complete the following information):

  • Node Red Version: 0.18.5
  • NR Home Assistant Plugin Version: 0.3.1
  • Is Node Red running in Docker: no
  • Home Assistant version: 0.83.2

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: Yes - there were previous reports of entity id field not auto filling however bug did not seem to match this behavior.
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): Did not attempt

Additional context
Add any other context about the problem here. Everything was running fine pre Home Assistant 0.83.X upgrade (Received 0.83.1 first, which had problems with auth and 0.83.2 was recieved a few hours later which resolved those issues.)

Using token auth with home assistant. Not using api_password

Call service node edit also has an issue auto populating the service/entity id fields with autofill. and 2 errors are displayed:

TypeError: Cannot read property 'getServices' of undefined
at ConfigServerNode.getServices (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/nodes/config-server/config-server.js:21:18)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at /usr/lib/node_modules/node-red/red/api/auth/index.js:63:13
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:335:12)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:275:10)
at /usr/lib/node_modules/node-red/node_modules/express/lib/application.js:233:9
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:635:15
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:260:14)
at expressInit (/usr/lib/node_modules/node-red/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)

TypeError: Cannot read property 'getEntities' of undefined
at ConfigServerNode.getEntities (/home/pi/.node-red/node_modules/node-red-contrib-home-assistant-websocket/nodes/config-server/config-server.js:9:18)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at /usr/lib/node_modules/node-red/red/api/auth/index.js:63:13
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/usr/lib/node_modules/node-red/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:335:12)
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:275:10)
at /usr/lib/node_modules/node-red/node_modules/express/lib/application.js:233:9
at /usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:635:15
at next (/usr/lib/node_modules/node-red/node_modules/express/lib/router/index.js:260:14)
at expressInit (/usr/lib/node_modules/node-red/node_modules/express/lib/middleware/init.js:40:5)
at Layer.handle [as handle_request] (/usr/lib/node_modules/node-red/node_modules/express/lib/router/layer.js:95:5)

How to migrate to this module?

Hi, thanks for creating this module. Could you explain how to migrate from node-red-contrib-home-assistant (with existing nodes using that module)? Because when I install your module, it tries to register nodes that already exist because the names are identical. And then I also can't uninstall the module anymore from the NR interface as it reports being 'in use'.

High CPU usage due to reconnection issues

I'm using the Node Red add-on (v1.2.3 containing library version v0.5.1) on Hassio (v0.85.1). When restarting Home Assistant, Node Red continuously tries to reconnect hundreds of times causing a high CPU load.

schermafbeelding 2019-01-13 om 18 19 01

schermafbeelding 2019-01-13 om 18 19 52

/homeassistant/entities is publicly available without auth

It would appear that even when the UI is configured to have basic authentication (the only one i've tested), the /homeassistant/entities url can still be accessed without any authentication.

This can be a problem if node-red is publicly exposed since it's leaking all entity names to unauthorized callers.

Environment (please complete the following information):

  • Node Red Version: 0.19.4
  • NR Home Assistant Plugin Version: 0.1.1
  • Is Node Red running in Docker: yes

Output Initially / On Deploy

Is your feature request related to a problem? Please describe.
Consider outputting state on the deployment of a node, not just the deployment of the configuration node

Describe the solution you'd like
An update to the existing option Output Initially / On Deploy for the trigger-state or state-changed nodes or an additional option.

Describe alternatives you've considered
A simple inject with current-state node does the trick, but it can be cumbersome

Additional context
This is only really a problem when the deployment mode is set to partially deploy a single flow or changed nodes only.

Connecting 2 output nodes to a template node causes error

Describe the bug
when using the get template node i get the following error:

Error calling service, home assistant api error: Cannot set property headersSent of #<OutgoingMessage> which has only a getter

To Reproduce
Steps to reproduce the behavior:

  1. Connect a inject node call template node connect the template node to 2 debug nodes.
  2. Click on 'run it'
  3. See error

Expected behavior
it should log 2 messages.

Screenshots
image

Example Flow

[{
		"id": "87a2a4aa.0b9c38",
		"type": "tab",
		"label": "Test",
		"disabled": false,
		"info": ""
	}, {
		"id": "a86fc2d0.91f45",
		"type": "inject",
		"z": "87a2a4aa.0b9c38",
		"name": "",
		"topic": "",
		"payload": "",
		"payloadType": "date",
		"repeat": "",
		"crontab": "",
		"once": false,
		"onceDelay": 0.1,
		"x": 160,
		"y": 80,
		"wires": [["5cf27320.48e14c"]]
	}, {
		"id": "5cf27320.48e14c",
		"type": "api-render-template",
		"z": "87a2a4aa.0b9c38",
		"name": "test",
		"server": "fa4c0dcc.2c6f8",
		"template": "{% for state in states.plant if state.state == 'problem' -%}\n  {%- if loop.last and not loop.first %} och {% elif not loop.first %}, {% else %} {% endif -%}\n  {{ state.name }}\n{%- endfor %}",
		"x": 330,
		"y": 80,
		"wires": [["f9ce677c.430f18", "5c0ff37c.23676c"]]
	}, {
		"id": "f9ce677c.430f18",
		"type": "debug",
		"z": "87a2a4aa.0b9c38",
		"name": "",
		"active": true,
		"tosidebar": true,
		"console": false,
		"tostatus": false,
		"complete": "false",
		"x": 710,
		"y": 80,
		"wires": []
	}, {
		"id": "5c0ff37c.23676c",
		"type": "debug",
		"z": "87a2a4aa.0b9c38",
		"name": "",
		"active": true,
		"tosidebar": true,
		"console": false,
		"tostatus": false,
		"complete": "false",
		"x": 710,
		"y": 180,
		"wires": []
	}, {
		"id": "fa4c0dcc.2c6f8",
		"type": "server",
		"z": "",
		"name": "Home Assistant",
		"legacy": false,
		"hassio": false,
		"rejectUnauthorizedCerts": true,
		"ha_boolean": "y|yes|true|on|home|open"
	}
]

Environment (please complete the following information):

  • Node Red Version: [0.19.5]
  • NR Home Assistant Plugin Version: [0.5.1]
  • Is Node Red running in Docker: [yes(x64, debian 9 host)]

Ignore SSL

I am having issues with being able to use a certificate signed by my root certificate. I have tested and I can curl https:\homeassitanturl:8123\ from node-red server without a error but soon as I add it to node-red it fails.

I found in node-red-contrib-home-assistant-websocket/lib/ha-websocket.js
Line 242:
const socket = new WebSocket(url);

I had wondered about a config option to do this:

const socket = new WebSocket(url, {
  rejectUnauthorized: false
});

I would love for it to recognize my root certificate but I have yet to find why it can't verify it.

Server settings are nog capt

Describe the bug
I have e new docker container whit Node Red, install this HA component, select a Node, setup te server deploy it, Then is get a message server not found..

When i open the setup detail every thing is empty....

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
image

Example Flow
If applicable, add an example of exported json of a flow exhibiting the issue to aid in reproduction.

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.0
  • Is Node Red running in Docker: yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?:

Additional context
Add any other context about the problem here.

Template node leaks sensitive data if empty result

Describe the bug
If you execute a template node, that yields a empty result the entire http request is placed as payload including the Bearer token.

To Reproduce
Steps to reproduce the behavior:

  1. Connect a inject node to a call template node to a debug node.
  2. Place template inside the node that will result in a empty result.
  3. Run
  4. Look in the debug message.

Expected behavior
No idea, but sensitive data should not be exposed?

Environment (please complete the following information):

  • Node Red Version: [0.19.5]
  • NR Home Assistant Plugin Version: [0.5.1]
  • Is Node Red running in Docker: [e.g. yes]

Installation problem on Raspberry pi

Describe the bug
npm install fails

To Reproduce
Run npm install

Expected behavior
The package should be installed

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.1
  • Is Node Red running in Docker: no

Additional context

This is what I get:

npm install node-red-contrib-home-assistant-websocket
npm WARN [email protected] requires a peer of marked@^0.3.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

npm ERR! path /home/pi/.node-red/node_modules/.date-fns.DELETE/difference_in_calendar_iso_weeks
npm ERR! code Unknown system error -117
npm ERR! errno -117
npm ERR! syscall unlink
npm ERR! Unknown system error -117: Unknown system error -117, unlink '/home/pi/.node-red/node_modules/.date-fns.DELETE/difference_in_calendar_iso_weeks'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-01-02T16_49_58_473Z-debug.log

Service_Domain of homeassistant, wont allow multiple enitities

Describe the bug
Since 0.4.3, my call service node with service domain of homeassistant fails with this in HA:
" Invalid service data for light.turn_off: Entity ID light.kitchen, light.rear_left is an invalid entity id for dictionary value @ data['entity_id']. Got ['light.kitchen, light.rear_left'] " If I remove all but one entity, it works again. Two or more it fails. Light, switch, a combination, it doesn't matter. This is data configured in the node, not passed to the node, btw.

To Reproduce
Steps to reproduce the behavior:
Create a call service node with two or more entities. Use the homeassistant service_domain. Try it out, it fails quietly in node-red, but HA returns an error. If you change it to a light service_domain, it starts working again (assuming entities are lights).

Expected behavior
Two or more entities used to work.

Screenshots
If applicable, add screenshots to help explain your problem.

Example Flow
If applicable, add an example of exported json of a flow exhibiting the issue to aid in reproduction.

Environment (please complete the following information):

  • Node Red Version: 19.5 / HA: 83.3
  • NR Home Assistant Plugin Version: 0.4.3
  • Is Node Red running in Docker: Yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: Yes
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): I'm sorry, I dont see anything about a dev docker env.

Hass.io support URL/Token fields

Is your feature request related to a problem? Please describe.

I've learned, especially the last couple of days, a lot of users have issues with the concept of http://hassio/homeassistant is actually a valid and recommended URL to use.

This causes people to change it, and end up having difficulties (while it worked out of the box.)

And even if they keep the correct URL, they have no clue what to put into the API Token field.

Describe the solution you'd like

Add a checkbox for: I use Hass.io (or something) and hide both URL & API token fields.

Describe alternatives you've considered

Hide the API Token field if the http://hassio/homeassistant URL is used.

Additional context

n/a

Using the new oauth from homeassistant

I am trying to use the new oauth login scheme from homeassistant with your module, but what am I supposed to enter in the AccessToken-field. Do you have an example for this scenario?
I am starting with a fresh install of homeassistant and nodered with only some hue lights configured in HA

Error calling service, home assistant api error

Describe the bug
Receiving this error in node-red: "Error calling service, home assistant api error"

Environment (please complete the following information):

  • Node Red Version: 0.18.7

  • NR Home Assistant Plugin Version: 0.5.1

  • Is Node Red running in Docker: yes

  • HA Version: 0.73.1 (too many breaking changes since to do a quick update to a more recent build)

  • Have you searched previous issues for duplicates?: Yes

Additional context
I found issue #3, but it doesn't apply here.

I've had this installed and working for some time now. I updated the plugin from v0.2.1 to 0.5.1 the other day. After this I started getting the "Error calling service, home assistant api error" errors.
The thing is, the calls seem to be working - but an error is logged each time.

For example I have a simple test flow with an inject node connected to a call service node to turn off a light. After injecting the light turns off, but I receive 2 errors in the debug log:

screenshot 2019-01-02 14 42 01

events: state outputs even when state does not change

Describe the bug
The "Events: state" node description says it outputs state-changed events from Home Assistant. However, it outputs events even when the state did not change. I have a z-wave power plug that when it's turned on or off, i get two events output from the node. The first appears to be when the state actually changes from "on" to "off" or vice versa. The second, I believe, is a power report being sent from the plug. This seems to trigger a state changed event, but the state does not, in fact, change.

For example, turning plug from off to on. Two messages emerge from the node immediately:

  • the first message has state: "on", old_state: "off" and new_state: "on" (expected)
  • the second message two has state: "on", old_state: "on" and new_state: "on" (not expected)

Message 1 (left) and Message 2 (right)
screen shot 2019-01-04 at 11 39 09 amscreen shot 2019-01-04 at 11 39 18 am

To Reproduce
Steps to reproduce the behavior:

  1. Find a device that outputs messages that do not change the state - my use is a z-wave power plug that sends power reports.
  2. Put a debug node the "events: state" node for the device in 1)
  3. watch messages emerge from the node where the state does not change
  4. See error

Expected behavior
The node should not output the second message because the "state" did not change. Perhaps the node needs to compare msg.data.old_state.state and msg.data.new_state.state to make sure there is actually a state change.

Screenshots
If applicable, add screenshots to help explain your problem.

Example Flow
image

Environment (please complete the following information):

  • Node Red Version:0.19.5
  • NR Home Assistant Plugin Version: 0.5.1
  • Is Node Red running in Docker: yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes

hassio Domain not available in api-call-service

Is your feature request related to a problem? Please describe.
The problem has been described in this issue for the hassio node-red addon:
hassio-addons/addon-node-red#99

Describe the solution you'd like
I would like to be able to call hassio related services such as 'hassio.snapshot_full'

Describe alternatives you've considered
no alternatives are known by me at this point.

Cannot GET /homeassistant/entities

Describe the bug
A clear and concise description of what the bug is.
When I place a nodetype that requires to fetch entities from HA it gives this error message: "Cannot GET /homeassistant/entities"

To Reproduce
Steps to reproduce the behavior:

  1. Go to node-types->homeassistant
  2. Place a "polls state"
  3. Doubleclick on the node
  4. See error

Expected behavior
Show all entities from HA

Screenshots
If applicable, add screenshots to help explain your problem.

Example Flow
If applicable, add an example of exported json of a flow exhibiting the issue to aid in reproduction.

Environment (please complete the following information):

  • Node Red Version: 0.19.4
  • NR Home Assistant Plugin Version: 0.0.1 according to nodered palette
  • Is Node Red running in Docker: no

Other (please complete the following information):

  • Have you searched previous issues for duplicates?:
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md):

Additional context
I am running NR and HA in docker.
In NR I set the baseurl for HA to "http://homeassistant:8123"

Time displays in UTC

Saw someone closed this issue a few weeks ago, but it's happening to me and I can't explain why.
running node red docker container latest v8, node red version 19.5.
Home assistant is latest version, .86, also running in docker (not hass.io), and I am authenticating using long live token.

I generated the container using docker-compose, and I have the volumes "/etc/localtime:/etc/localtime:ro" and
"etc/timezone:/etc/timezone:ro" set. I am located in UTC -5 (EST), but my "call service" node shows a timestamp with standard UTC time, 5 hours later than my local time.
All other nodes in node red and debug messages show the correct local time, as well if I run the "date" command inside the docker container. This is definitely an issue specific to the service node I am using, not node red itself. See image for proof -
Imgur

Cannot save flow because of server and api-call-service

Describe the bug
When trying to save nodes by node-red-contrib-home-assistant-websocket, I get the following problem:

Flows stopped due to missing node types.
 * server
 * api-call-service

To Reproduce
Steps to reproduce the behavior:

  1. Install node-red-contrib-home-assistant-websocket

  2. Add Call Service node and add settings

  3. Save

  4. Try using HTTP Request

Expected behavior
Allow me to save, or explain why it's failing.

Screenshots

Trying to save

Package

Not sure what's going on here.

Image

Settings

What's strange is that the Base URL and Access Token disappears after save, regardless if using http://<host ip>:8123 or https://homeassistant.domain.tld which is proxied.

Settings

Environment (please complete the following information):

  • Node Red Version: 0.19.5

  • NR Home Assistant Plugin Version: e.g. 0.5.0

  • Is Node Red running in Docker: yes

  • Have you searched previous issues for duplicates?:
    Yes

Plugin does not connect to HA after reboot

Describe the bug
On an Hassbian Raspberry Pi 3, Home assistant and Node red configured to launch at startup, just after the raspberry boot, NodeRed can't connect to Home assistant.
Redeploying nodes in NodeRed or restart once Home assistant, solves the issue and NodeRed connects well to Home-Assistant

Expected behavior
NodeRed must connect to Home Assistant after a boot without restarting HA or NR.

Environment (please complete the following information):

  • Node Red Version: 0.19
  • NR Home Assistant websocket Plugin Version: 0.1.2
  • Is Node Red running in Docker: no

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): no

By the way, very good plugin ! Keep this way !

Thank you

Status Messages are in UTC

Status messages should be presented in local time with 24 hour format to be cosistent with the rest of Node-Red

Ability to inject Entity ID onto Current_state

Is your feature request related to a problem? Please describe.
With Call_service you are able to inject data into it.

image

image

The only problem is I am not able to do the same with current_state:

image

image

I get this error:

msg : string[34] ""value" is not allowed to be empty"

Describe the solution you'd like
Ability to act like call_server

Document connecting, open, close, error, states_loaded, services_loaded events.

When node red first boots up, sometimes it's good to set up some state in HA. There's a delay however between node red firing up and HA being ready.

One example of how this would be used is to set up stuff based on the time of day, where you'd want to initialise everything on connection.

Describe the solution you'd like
A connection state node, outputs topic.connected when connected, and topic.disconnected when disconnected. Each of these messages could possibly be optional.

It might also be an idea to have a list of entities that have to have their state available before the connected gets fired. This would work well for example with z-wave entities that can take a little while to boot up.

I can possibly contribute this myself, I've got some time off work coming up in a few weeks.

Areas

Having areas in node-red would be amazing. I checked in node-home-assistant.js and I don't see getAreas so unless I am looking in the wrong places I don't believe its currently supported. Right now I do a lot of this through names matching patterns and determining room\area but this would allow me to control devices easily based on what room they are in.

Thanks in Advance!

History node returns all entities when using "is" entity ID filter

Describe the bug
I'm using the package's get history node to get the last 15 min min of a specific entity.
When using the entity ID is sensor.mysensor, then all HA events from the last 15 min are returned.
The includes filter works as expected, but I'd love to make my requests faster with the API filter_entity_id URL parameter.

To Reproduce
Steps to reproduce the behavior:

  1. Add a history node in Node RED
  2. Configure it with a specific entity ID and the "is" filter
  3. Specify a valid start and end time
  4. All events from all entities within the time span are returned

Expected behavior
Only the events from the specified entity within the time span are returned.

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.1.3
  • Is Node Red running in Docker: yes, via the official HassIO addon in version 1.0.1

Thanks a lot! :)

No entity for all in service call is deprecated

hassio log entry :
Not passing an entity ID to a service to target all entities is deprecated. Update your call to light.turn_off to be instead: entity_id: all

But I can't set "all" to the entity id into the service call node.

Mustache template in call service node needs to be rendered before stringified?

I'm having trouble using the mustache templates in the call service node, data field.

I'm populating the callback query_id field with a number located in msg.payload.event.id but this isn't valid json as it sees the mustache template as a being a string and not a number, which it should be.

{
    "message": "Lights have been turned off",
    "callback_query_id": {{msg.payload.event.id}}
}

Could this be because the mustache template is not being rendered until after it is parsed as a json string?

Error: Cannot find module 'joi'

Using docker container nodered/node-red-docker:0.19.5-rpi-v8 for arm64 I get the following error:

28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/server] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/server-events] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/server-state-changed] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/trigger-state] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/poll-state] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/api-call-service] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/ha-fire-event] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/api-current-state] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/ha-get-entities] Error: Cannot find module 'joi'
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/api-get-history] Error: Cannot find module 'joi' (line:1)
28 Dec 16:14:34 - [warn] [node-red-contrib-home-assistant-websocket/api-render-template] Error: Cannot find module 'joi' (line:1)

Override input data when calling the service

Describe the bug
I'm not sure it's me not knowing how to do things yet, or it's a missing feature. I'd like to be able to override input payload when using call service node.

To Reproduce

  1. Chain two call service nodes. First that calls timer.cancel and second that calls timer.start with same entity_id

Expected behavior
That timer.cancel is called first and then timer.start

Actual behavior
timer.cancel is called twice as output payload from first node is passed and used by the second node.

Example Flow

[{"id":"679207b1.7ae398","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"78d118ff.4a3a58","type":"trigger-state","z":"679207b1.7ae398","name":"On door opened","server":"88a88639.b89d78","entityid":"binary_sensor.telldus_tzdw100_magnet_switch_sensor","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"a3z34r1tall","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"x":100,"y":120,"wires":[["b02763eb.3ccd9","e04f42a6.3ec28"],[]]},{"id":"14045802.eba358","type":"api-call-service","z":"679207b1.7ae398","name":"Turn ON","server":"88a88639.b89d78","service_domain":"homeassistant","service":"turn_on","data":"{\"entity_id\":\"switch.kitchen_switch\"}","render_data":false,"mergecontext":"","x":580,"y":80,"wires":[[]]},{"id":"b02763eb.3ccd9","type":"api-current-state","z":"679207b1.7ae398","name":"If kitchen light OFF","server":"88a88639.b89d78","halt_if":"on","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"switch.kitchen_switch","x":390,"y":80,"wires":[["14045802.eba358"]]},{"id":"fa5cf4bf.12a668","type":"api-call-service","z":"679207b1.7ae398","name":"Start timer","server":"88a88639.b89d78","service_domain":"timer","service":"start","data":"{\"entity_id\":\"timer.kitchen\"}","render_data":false,"mergecontext":"","x":1090,"y":160,"wires":[[]]},{"id":"64d6653c.52f83c","type":"api-current-state","z":"679207b1.7ae398","name":"timer.kitchen state","server":"88a88639.b89d78","halt_if":"","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"timer.kitchen","x":670,"y":140,"wires":[["f7608503.c343b8"]]},{"id":"e04f42a6.3ec28","type":"api-current-state","z":"679207b1.7ae398","name":"If no kitchen movement","server":"88a88639.b89d78","halt_if":"on","override_topic":true,"override_payload":true,"override_data":true,"entity_id":"binary_sensor.aeotec_zw100_multisensor_6_sensor","x":430,"y":140,"wires":[["64d6653c.52f83c"]]},{"id":"f7608503.c343b8","type":"api-call-service","z":"679207b1.7ae398","name":"Cancel timer","server":"88a88639.b89d78","service_domain":"timer","service":"cancel","data":"{\"entity_id\":\"timer.kitchen\"}","render_data":false,"mergecontext":"","x":890,"y":160,"wires":[["fa5cf4bf.12a668"]]},{"id":"88a88639.b89d78","type":"server","z":"","name":"Home Assistant"}]

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 1.2.0
  • Is Node Red running in Docker: yes

Other (please complete the following information):

  • Have you searched previous issues for duplicates?: yes
  • Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md): yes

Additional context
Add any other context about the problem here.

Trigger Node Help Information Missing

This information has been missing since the original, original node-red plugin. Can it be updated?
By the way Jason, thanks for making this, it is truly awesome.

image

Cannot GET /homeassistant/36cb91e9.fdc0ce/entities

Describe the bug
Error is thrown after giving Home Assistant server information in state_changed node.

To Reproduce
Steps to reproduce the behavior:

  1. Drop state_changed node to flow
  2. Double click to open node editor
  3. Add new server (mostly default values, I gave access token)
  4. Click Add
  5. Get error message "Cannot GET /homeassistant/36cb91e9.fdc0ce/entities". From browsers network log request shows as failed with status 404.

Screenshot

screenshot

Expected behavior
There should not be error popup and home assistant entities are browsable in node editor.

Environment (please complete the following information):

  • Node Red Version: 0.19.5
  • NR Home Assistant Plugin Version: 0.5.0
  • Is Node Red running in Docker: no

Other (please complete the following information):

Might be related to these #2 #50

Wait Node (possible new node) looking for feedback

Have a new node sort of mocked up but not sure if it's worth implementing because its use can be duplicated with several other nodes. It's basically a copy of the wait condition in Home Assistant.

https://www.home-assistant.io/docs/scripts/#wait

WAIT

Wait until some things are complete. We support at the moment wait_template for waiting until a condition is true, see also on Template-Trigger. It is possible to set a timeout after which the script will continue its execution if the condition is not satisfied. Timeout has the same syntax as delay.

A possible use case could be:

You have a household member arriving home and you want to greet them by name when the front door is opened. First, have an event-state node trigger when a person's state goes from not home to home then a wait node that will trigger when the front door sensor changes which then fires the TTS to HA.

chrome_2019-01-22_20-35-41

Here's the editor window

chrome_2019-01-22_20-32-14

The output of the node right now has two outputs. One for if the condition becomes true and the second if the timeout occurs. Another option could be to only have one output that would add a property to the msg object, msg.timedout = true if the timeout occurred.

The node would also accept a msg object with the property of msg.reset to reset the node and cancel any current wait/timeouts in progress.

Questions?

  1. Would this node be useful?
  2. What format should the Timeout be in, seconds or in the same format as Home Assistant 00:00:01? I am leaning towards seconds to keep it in-line with the poll-state node.
  3. Which output option? Two outputs or one with an extra property on the msg object.
  4. What should the default be for Continue on Timeout, checked or not checked?

Any other suggestions or improvements?

Override data control in current state

Is your feature request related to a problem? Please describe.
The current-state node allows control of topic and payload override, but not the data.

Describe the solution you'd like
Add support for control of override data

Describe alternatives you've considered

Additional context
In the original node-red-contrib-home-assistant, I had modified the current-state node to fix a logic bug that was in a PR but not merged. While in there, I also added override data control to the node. I found this useful to be able to halt a flow based on a condition, but otherwise let whatever the input to the current-state was continue on through.

One simple example is I have all my door sensors (server-state-change nodes) flow into a single current-state node that checks an input_boolean that controls if that flow should run. It halts if off, but otherwise doesn't override anything and the flow continues.

This should be able to be added and not break anything with the right default. If this sounds useful, happy to put up the PR. If I'm missing something, happy to be educated :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.