Using Home assistant nod red nodes in node red

Hello all

I was communicating with Node red support and they suggested i post this question in this forum

I have this automation running in home assistant and it works perfectly

However in node red the call service node to turn on light does not override the shelly lightbulb brightness setting in the shelly app.

The requirements are:

If notion is detected
check luminosity if below 5
check time range if daty time the turn on light brightness 60%. If night time turn on light brightness 20%

s outlined in the flow the does go to full completion in both timeframes.

If i set the light level of the bulb in the shelly app the flow will turn on the light at the bulb setting and not as the prescribed 60 or 20% (this is my issue).

As far as I can see the luminance level is a set condition on which to trigger and continue the flow.

I am definitely to inexperienced to identify if the illuminance node changes the message. As far as i see it it only acts as a threshold

In the time range node I interpreted it as being the top level true (within day time) and the lower connection would be false for all event outside the day time range . Therefore night shift. I do not know it it creates a message IMHO i think it only is setting the parameters for day and night. In the debug node i do not see any evidence of any new or additional message.

Just to mention yesterday the flow was divided in 2 separate flows one for day and one for night.

I had the same issue with both of these

At least this is my understanding
I just tested the sequence and here is a copy of the debug nos for the flow

12/3/2023, 3:19:08 PM[node: Motion Detected](http://192.168.1.112:8123/api/hassio_ingress/JeXK6fWVzk2zs66R1f1inIgAejGgIEVbYkOEpL_3X6Q/#)msg : Object

object

payload: "on"

data: object

entity_id: "binary_sensor.multisensor_6_motion_detection"

old_state: object

entity_id: "binary_sensor.multisensor_6_motion_detection"

state: "off"

attributes: object

device_class: "motion"

friendly_name: "Entrance Hall Sensor Motion detection"

last_changed: "2023-12-03T12:26:43.080121+00:00"

last_updated: "2023-12-03T12:26:43.080121+00:00"

context: object

id: "01HGQTAB08DZTGEV0VFCGSPGC1"

parent_id: null

user_id: null

new_state: object

entity_id: "binary_sensor.multisensor_6_motion_detection"

state: "on"

attributes: object

last_changed: "2023-12-03T14:19:08.161314+00:00"

last_updated: "2023-12-03T14:19:08.161314+00:00"

context: object

timeSinceChangedMs: 3

topic: 0

_msgid: "583399c1b4cf48f7"

12/3/2023, 3:19:08 PM[node: Illuminance](http://192.168.1.112:8123/api/hassio_ingress/JeXK6fWVzk2zs66R1f1inIgAejGgIEVbYkOEpL_3X6Q/#)msg.payload : number

8

12/3/2023, 3:19:08 PMLight on Daysent data : msg :

object

domain: "light"

service: "turn_on"

data: object

area_id: "entrance_hall"

device_id: "79672ab21f9ab0c866d2d8a2259e60ac"

entity_id: "light.shelly_shbduo_1_98cdac2ba9b9"

12/3/2023, 3:19:08 PM[node: Time of Day](http://192.168.1.112:8123/api/hassio_ingress/JeXK6fWVzk2zs66R1f1inIgAejGgIEVbYkOEpL_3X6Q/#)msg.Time of day : undefined

undefined

12/3/2023, 3:19:08 PM[node: Light on 60%](http://192.168.1.112:8123/api/hassio_ingress/JeXK6fWVzk2zs66R1f1inIgAejGgIEVbYkOEpL_3X6Q/#)msg.payload : number

8

The light did turn on (by coincidence it was set at 60%) at 60% and after the set time it did turn off

as far as i understand as long as the motion detection sensor is on
the luminance and the time are on conditions to be met in order to turn on the light.

I do not know what message is required by the bulb for the luminance to be overridden…
In the home assistant automation I do not need to set, send. or input any additional parameters

Thank you for your help

You could first get the call service working in Dev Tools, and then convert the YAML to JSON for Node Red.

I would expect you to be setting “brightness_pct” to 20 or 60, however you haven’t posted what msg.payload.data is set to, so it’s hard to know what’s wrong.

Also, you shouldn’t need to set area and device and entity - just entity. Otherwise you’re making a lot of work for yourself it you change areas or replace the light.

1 Like

@michaelblight thank you for your response

Let’s start with the msg.payload.data I do not know where to look for this

I did create a flow just to turn on light with an inject node with msg.payload =on
it turns on the light however it does not account for the “brightness_pct” setting.

I am pasting a copy of the export of my debug node for this test


` [{"id":"7d5181fd7d99c139","type":"tab","label":"Light based upon time","disabled":false,"info":"","env":[]},{"id":"b0da6db6b190679c","type":"api-call-service","z":"7d5181fd7d99c139","name":"Light on Day","server":"8687e46ec9bc620c","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["79672ab21f9ab0c866d2d8a2259e60ac"],"entityId":[],"data":"{“brightness_pct”:10}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":200,"wires":[["c02ab706d2819623"]]},{"id":"e9f64f92463b7f0f","type":"inject","z":"7d5181fd7d99c139","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":170,"y":200,"wires":[["b0da6db6b190679c","5a7135dbc64a3cf2"]]},{"id":"5a7135dbc64a3cf2","type":"debug","z":"7d5181fd7d99c139","name":"inject","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":330,"y":120,"wires":[]},{"id":"c02ab706d2819623","type":"debug","z":"7d5181fd7d99c139","name":"light on","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"jsonata","statusVal":"","statusType":"auto","x":560,"y":120,"wires":[]},{"id":"8687e46ec9bc620c","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"numeric","statusMonth":"short","statusDay":"2-digit","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":false}]

I understand the issue with the msg.payload in node red (this is a msg that seems not to exist missing in my setup) and i am certain that this is the culprit

If i look in file editor (without touching it) i do see the HA automation to turn on light @60% and 20%

As i said the HA automation works flawlessly

The above was formatted with </>

Playing with yaml and json is miles beyond my horizon of comfort, knowledge and capabilities.

Thank you once again for your help

Worse.
Adding those will actually make calls to both the entity, device and area, which might actually cause issues like the one described, so start with just using an entity in the service call.

@WallyR

I tried this by
A) replacing the bulb at the same location and naming the device differently in the flow
B) putting the original bulb in a different room (not changing the name)
C) built a new flow with the new bulb

none of these actions resolved my issue

It has to be a message or a signal that the call action node is not transmitting to the bulb.

Other than the brighness_pct issue the flow works perfectly
Thank you all for your help

As michaelblight mentioned…get the service call to work in HA first.
NR just calls that service call, so if HA can set the brightness, then NR can too and you just need to give the same parameters.
If HA can not set the brightness, then working with NR is useless.

1 Like

The way you have the data formatted should be set to JSON and not expression.

@WallyR hello in HA my light automation does work with the same entities.
By this i mean it turns on the light at the selected brightness based upon time of day

Using the same and identical devices and entities in NR the light turn on without the taking into consideration of the brightness_pct value

@nickgeorge333 thank you for the suggestion. I did try that and hurrah it worked on the test environment.

Tonight i will try it live

Thank you vert much for spotting this this is for one a great help in solving the issue and 2 an excellent training (Even though i do not know and understand the difference and when to apply JSON vs expression which is characterised with a large and bold J

thank you for your response

and thank to all who have helped this is greatly appreciated
May I suggest that to assist dumb individuals like myself that the documentation be a little more precise.

How can I contribute forward?

This is a very simple flow yet it took a lot of time to resolve. Can i post my flow/experience somewhere in order to be helpful myself?

Make a post here with the flow and tell us about it.
Others (and yourself) can then find the solution to the issue later, which is really appreciated by the forum users, both the ask’ers and the answer’ers. :slight_smile: