What's the recommended method for Smart Life devices with Node Red?

I’ve just spent the better part of 2 hours tried to get a light bulb to turn off and on.

I have the bulb entity in my dashboard, and can turn it off an on ( I can confirm by seeing the bulb) – So that works. This is a Smart Life bulb.

I’m trying to configure Node Red to turn that bulb on and off at a specific time.

My questions are

What is the inject node to use for testing in Node Red?
How should this be set up? I tried using the the entity directly in Node Red (not a switch) but that didn’t work either.

Recommendations?

Just to confirm, you have added your Smart Life Bulb into HomeAssistant, and can control it from Lovelace Dashboard and via HomeAssistant Service calls, correct?

@AlmostSerious – Yep, I can control the light in Lovelace…

I’m not entirely sure what “Service Calls” means… Does that mean from the dashboard?

With Service Call I mean the actual underlying service that is called in the background when you interact with something from the Dashboard.
You can also invoke the Service Call directly when you go to Developer Tools / Services.
The NodeRed basically uses exactly the same call, but instead of yaml formatting its JSON formatting. This is a great way to test for correct commands.

image

Hi @AlmostSerious

Having never used this function before, I had to upgrade. But yep, I can indeed turn the light on and off with the service call

first of learn how to export your nodered diagram code to make us know how you setup your nodes. picture doesn’t show everything.
You can find export feature in top-right corner.
then paste it to this forum as a code.

Inject is a node to generate desired values. ussually to start a flow (flows must be started by some events, either comming from HA. or from inject. inject can.

For toggling light it’s ebouth to have inject node returning any value (ie timestamp) and service node. the latter set to light domain, your entity, service: toggle, turn_on or turn_off. I would chose toggle at first.
In this configuration any press on inject node should toggle your light

Great so in this case, you would simply translate what you see there to the NodeRed Service Call Node.

Like this:

Thanks guys. I can now use the inject node to trigger the light on and off. Thanks much @AlmostSerious
@maxym - will post my working node red for others when its done.

appreciate all the help!

Here is what I did for a timer.
On at 18:00
Off at 0600
Each with a different call service node. I’m sure there are easier ways but this worked first time. Thanks

[{"id":"8584c693.177528","type":"tab","label":"Timers","disabled":false,"info":""},{"id":"e2f3ab1d.a9c658","type":"api-call-service","z":"8584c693.177528","name":"Turn on Front Door Bulb","server":"1a6b405.32c5dc","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.eb2069566b508ad1ff0rof","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":430,"y":100,"wires":[[]]},{"id":"8e916a4.cefac98","type":"api-call-service","z":"8584c693.177528","name":"Turn off Front Door Bulb","server":"1a6b405.32c5dc","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.eb2069566b508ad1ff0rof","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":430,"y":240,"wires":[[]]},{"id":"802c2ad4.ed9898","type":"schedex","z":"8584c693.177528","name":"Night (On)","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"18:00","ontopic":"","onpayload":"On","onoffset":0,"onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"Off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":120,"y":120,"wires":[["1948fa9.dd43c05","e2f3ab1d.a9c658"]]},{"id":"55d7a3ba.cfdf6c","type":"schedex","z":"8584c693.177528","name":"Daytime (Off)","passthroughunhandled":false,"suspended":false,"lat":"","lon":"","ontime":"","ontopic":"","onpayload":"","onoffset":0,"onrandomoffset":0,"offtime":"05:50","offtopic":"","offpayload":"Off","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":130,"y":220,"wires":[["1948fa9.dd43c05","8e916a4.cefac98"]]},{"id":"1948fa9.dd43c05","type":"debug","z":"8584c693.177528","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":160,"wires":[]},{"id":"1a6b405.32c5dc","type":"server","z":"","name":"Home Assistant"}]

Hopefully that can help someone else in the future. Thank you @AlmostSerious