# Recommendations for the new guy?

**URL:** https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929
**Category:** General
**Created:** [25 June 2020 02:26 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929 "2020-06-25T02:26:36Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [1 July 2020 03:03 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/21 "2020-07-01T03:03:09Z")

</div>

(bashing head against wall)

If you send a message to the _bulb_ (I'm going to call it the light) and it is:  
`{msg.brightness_pct:100}`  
It will set the brightness to 100. Or I hope it will. If it doesn't we are wasting time.

I am so close to just walking away from this. I can't deal with what is happening.  
I am sitting here and you seem intent on changing things for no other reason than to annoy me.

The only time the brightness of the light is _known_ is when it spits out a message and you use that message.  
That is a recipe to disaster if you don't know what you are doing.  
And I have avoided doing this since your first attempts are adjusting brightness with redundant loops with in loops.

# forget everything we have done to now. I am starting again from square one.

Get an `inject` node connect it to a `change` node and connect that to the node that **directly** talks to the light.

Set it as this: (the light's node is not shown)

```auto
[{"id":"56f96dd1.ff641c","type":"inject","z":"b9924a74.4d98f8","name":"FULL","topic":"","payload":"100","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3560,"wires":[["75acecfc.325cbc"]]},{"id":"8fc9a816.32ed48","type":"inject","z":"b9924a74.4d98f8","name":"HALF","topic":"","payload":"50","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":3600,"wires":[["75acecfc.325cbc"]]},{"id":"75acecfc.325cbc","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"brightness_pct","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":3580,"wires":[[]]},{"id":"857a9be1.b1caa","type":"comment","z":"b9924a74.4d98f8","name":"put the node here.","info":"","x":560,"y":3580,"wires":[]}]

```

Ensure the light is ON.

Press the `HALF` button. The light should now be at half brightness.  
Press the `FULL` button. The light should now be at full brightness.

## Does this happen?

---

<div class="post-metadata">

### Author: ![repomanz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/repomanz/32/29106_2.png) [@repomanz](https://discourse.nodered.org/u/repomanz)
#### Post date: [1 July 2020 03:16 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/22 "2020-07-01T03:16:50Z")

</div>

> [@Trying\_to\_learn](#):
>
> I am so close to just walking away from this. I can't deal with what is happening.  
> I am sitting here and you seem intent on changing things for no other reason than to annoy me.

If you need to step away that is fine. I appreciate the input you've given to me regardless. To be clear, I am trying to demonstrate with you that I'm learning and along with your input I'm trying things on my own and not looking to be spoon fed the answer. It's not to annoy you.

> Press the `HALF` button. The light should now be at half brightness.  
> Press the `FULL` button. The light should now be at full brightness.
> 
> ## Does this happen?

No, it doesn't. I put a debug after your change object which results in this:

msg.payload : undefined  
undefined

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [1 July 2020 03:20 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/23 "2020-07-01T03:20:26Z")

</div>

I give up.

_We_ were so close.

I get you are _trying_ (Look at my name) But there are times when you have to do what is asked of you and report back. Changing things in the mean time only complicates things and wastes time for both parties. Yeah, I'm probably guilty of that myself.

But I just can't get my head around things. You say one thing one moment and another the next.

The nodes have to work. Gee, I hope they do. Or we are both wasting a lot of time.  
So you **must** send the **correct** message to the node to get things done.

I hope you can work it out.

---

<div class="post-metadata">

### Author: ![repomanz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/repomanz/32/29106_2.png) [@repomanz](https://discourse.nodered.org/u/repomanz)
#### Post date: [1 July 2020 03:25 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/24 "2020-07-01T03:25:57Z")

</div>

> [@Trying\_to\_learn](#):
>
> But there are times when you have to do what is asked of you and report back. Changing things in the mean time only complicates things and wastes time for both parties. Yeah, I'm probably guilty of that myself.

I've tried all the ideas you've mentioned plus some. The only thing that seems to work is setting the brightness\_pct attribute in the same node while calling the turn\_on service. (the original flow above).

I realize you're stepping away; thanks for all the help and see ya around in the forums. I'll report back once I find the answer.

---

<div class="post-metadata">

### Author: ![repomanz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/repomanz/32/29106_2.png) [@repomanz](https://discourse.nodered.org/u/repomanz)
#### Post date: [1 July 2020 03:55 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/25 "2020-07-01T03:55:18Z")

</div>

> [@Trying\_to\_learn](#):
>
> I hope you can work it out.

Of course. Now, i figured it out. I dug into the light component further and found a clue.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1be1b5acdc0bb79060cf1be7c2eae291b630971b.png)

```auto
[{"id":"ac362641.59d6f","type":"inject","z":"357f7858.e2e768","name":"FULL","topic":"","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":100}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1050,"y":1360,"wires":[["92aac620.18b948"]]},{"id":"1c1e59a3.1691fe","type":"inject","z":"357f7858.e2e768","name":"HALF","topic":"","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":50}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1050,"y":1420,"wires":[["92aac620.18b948"]]},{"id":"92aac620.18b948","type":"change","z":"357f7858.e2e768","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":1420,"wires":[["5ade64e7.a9c944","db5d95e1.72329"]]},{"id":"5ade64e7.a9c944","type":"debug","z":"357f7858.e2e768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1450,"y":1360,"wires":[]},{"id":"db5d95e1.72329","type":"api-call-service","z":"357f7858.e2e768","name":"kitchen - on","server":"8b533b83.ade2f8","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.kitchen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1450,"y":1420,"wires":[[]]},{"id":"2506d953.6b1b06","type":"inject","z":"357f7858.e2e768","name":"1/4","topic":"","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":25}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1050,"y":1480,"wires":[["92aac620.18b948"]]},{"id":"8b533b83.ade2f8","type":"server","z":"","name":"Home Assistant","addon":true}]

```

I now have the keys to finish out my cron flow I wanted to do. The missing elements was that I needed was to include an attribute entity\_id and then change the change object to msg.payload to msg.payload.data

queue up the Now You Know theme. (or I learned something)

---

<div class="post-metadata">

### Author: ![repomanz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/repomanz/32/29106_2.png) [@repomanz](https://discourse.nodered.org/u/repomanz)
#### Post date: [1 July 2020 14:41 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/26 "2020-07-01T14:41:52Z")

</div>

> [@Trying\_to\_learn](#):
>
> I hope you can work it out.

Really appreciate the help and guidance that ultimately led me to this new routine. Additionally created a light state timer in the off hours if someone turns the light on but forgets to turn it off.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03bc851392c63e1236c6b8c6d5656654c9966961.png)

```auto
[{"id":"bb4d83c3.2a0068","type":"cronplus","z":"357f7858.e2e768","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"7am","topic":"7am","payloadType":"json","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":25}","expressionType":"cron","expression":"00 7 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"8am","topic":"8am","payloadType":"json","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":50}","expressionType":"cron","expression":"0 8 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"9am","topic":"9am","payloadType":"json","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":75}","expressionType":"cron","expression":"00 9 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"9pm","topic":"9pm","payloadType":"json","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":100}","expressionType":"cron","expression":"00 21 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"9:30pm","topic":"9:30pm","payloadType":"json","payload":"{\"entity_id\":\"light.kitchen\",\"brightness_pct\":25}","expressionType":"cron","expression":"30 21 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"},{"name":"10pm","topic":"10pm","payloadType":"default","payload":"","expressionType":"cron","expression":"0 22 * * 1-5","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":820,"y":1160,"wires":[["41eff5a6.f58dec"]]},{"id":"10798237.a7d36e","type":"api-current-state","z":"357f7858.e2e768","name":"light on?","server":"8b533b83.ade2f8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.kitchen","state_type":"str","state_location":"payload","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1220,"y":1160,"wires":[["786b5f3d.58fe58"],[]]},{"id":"ac719223.6e8818","type":"api-call-service","z":"357f7858.e2e768","name":"kitchen - on","server":"8b533b83.ade2f8","version":1,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.kitchen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1630,"y":1140,"wires":[[]]},{"id":"786b5f3d.58fe58","type":"change","z":"357f7858.e2e768","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1410,"y":1160,"wires":[["ac719223.6e8818"]]},{"id":"41eff5a6.f58dec","type":"switch","z":"357f7858.e2e768","name":"start and end","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"7am","vt":"str"},{"t":"eq","v":"8am","vt":"str"},{"t":"eq","v":"9am","vt":"str"},{"t":"eq","v":"9pm","vt":"str"},{"t":"eq","v":"9:30pm","vt":"str"},{"t":"eq","v":"10pm","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":1020,"y":1160,"wires":[["1ec3e8fb.a7ff37"],["10798237.a7d36e"],["10798237.a7d36e"],["10798237.a7d36e"],["10798237.a7d36e"],["8fc9f8ef.af44b8"]]},{"id":"1ec3e8fb.a7ff37","type":"api-current-state","z":"357f7858.e2e768","name":"light off?","server":"8b533b83.ade2f8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.kitchen","state_type":"str","state_location":"payload","override_payload":"flow","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1220,"y":1100,"wires":[["f9e60af2.104288"],[]]},{"id":"f9e60af2.104288","type":"change","z":"357f7858.e2e768","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1410,"y":1100,"wires":[["ac719223.6e8818"]]},{"id":"8fc9f8ef.af44b8","type":"api-call-service","z":"357f7858.e2e768","name":"kitchen - off","server":"8b533b83.ade2f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.kitchen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1230,"y":1220,"wires":[[]]},{"id":"e3f3bb58.b7a2f8","type":"server-state-changed","z":"357f7858.e2e768","name":"5 minute","server":"8b533b83.ade2f8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.kitchen","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":820,"y":1300,"wires":[["317f08aa.9ed0e"],[]]},{"id":"6eb9870f.4eafc8","type":"comment","z":"357f7858.e2e768","name":"weekday lighting routine","info":"","x":870,"y":1060,"wires":[]},{"id":"84c31f19.0b44e8","type":"comment","z":"357f7858.e2e768","name":"lighting routine after 10pm","info":"","x":870,"y":1260,"wires":[]},{"id":"317f08aa.9ed0e","type":"time-range-switch","z":"357f7858.e2e768","name":"after hours","lat":"30.505198","lon":"-97.820290","startTime":"22:00","endTime":"07:00","startOffset":"","endOffset":"","x":990,"y":1300,"wires":[["6340569a.c39af8"],[]]},{"id":"6340569a.c39af8","type":"stoptimer","z":"357f7858.e2e768","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"5 minute","x":1160,"y":1300,"wires":[["992e259d.25073"],[]]},{"id":"992e259d.25073","type":"api-call-service","z":"357f7858.e2e768","name":"kitchen - off","server":"8b533b83.ade2f8","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.kitchen","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1330,"y":1300,"wires":[[]]},{"id":"8b533b83.ade2f8","type":"server","z":"","name":"Home Assistant","addon":true}]

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [30 August 2020 14:41 UTC](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929/27 "2020-08-30T14:41:56Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/recommendations-for-the-new-guy/28929.md?page=1)
