Home Automation - Smartkit

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I've got a very weird issue with Node Red and I'm not sure if I should worry about it or not.

zC7rB9U.png


Note that it says "cover.open_cover called at ..."

But it's passing "cover.close_cover" I thought it was maybe a copy and paste issue at first but then re-created it from scratch and I still see it like this.

mdpTsee.png


Home Assistant is receiving the correct thing presumably, even though in this particular case the payload is the same regardless. Where does one track this anyway?
That green text is not what you sent, but the last received status of the node. That node looks like it can be used for input and output, and that text is probably what it would send into the output side.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
47,848
That green text is not what you sent, but the last received status of the node. That node looks like it can be used for input and output, and that text is probably what it would send into the output side.

AAAAAAHHHH the penny drops.

That makes a whole lot of sense. I simply assumed based on other flows it was the action being done by the node itself.

I’ve got a workflow for my kid’s bedside light I should run past you guys later when at a desktop again which is a needless rinse and repeat to make it work but I’m sure there must be a cleaner way to loop it.

Only crap I have with Node Red is that it’s impossible to use on mobile.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
47,848
How can I get the Sunset/Rise as a middle node and not just an input?

ZyeGkl4.png


This, but not as the trigger.

Using the data from Home Assistant I have a problem with the times not quite matching.

1QvnTgS.png


So replace that middle node with the one that's the input at the first image.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
How can I get the Sunset/Rise as a middle node and not just an input?

ZyeGkl4.png


This, but not as the trigger.

Using the data from Home Assistant I have a problem with the times not quite matching.

1QvnTgS.png


So replace that middle node with the one that's the input at the first image.


Make use of function nodes and use code to save a variable that you can re-use.
Screenshot at 2019-07-24 21-04-08.png
In "Save Babyroom-heater-state" this is the code:
Code:
flow.set('babyroomheaterswitch', msg.payload);
return msg;

Then in my manage switch I have:
Code:
var switchstate = flow.get('babyroomheaterswitch')||'';
var floatval = parseFloat(msg.payload);

var time = new Date();
var displaytime = time.toLocaleTimeString();
var hour = time.getHours();

if(parseFloat(msg.payload) > 21){
    if(switchstate === "ON") {
        node.warn("Turning off switch. \nhour is " + hour + " temp is " + parseFloat(msg.payload))
        msg.payload = "OFF";
        return msg;
    } else { return; }
}

if(hour < 7 || hour >= 17){

    if(parseFloat(msg.payload) < 20){
        if(switchstate === "OFF") {
            node.warn("Turning on switch. \nhour is " + hour + " temp is " + parseFloat(msg.payload))
            msg.payload = "ON";
            return msg;
        } else { return; }
    }

}

//node.warn("Not changing switch. \nhour is " + hour + " temp is " + parseFloat(msg.payload))

return;

The code above is not important, what is important is that you can set and get variables. "flow" is specific to this flow. You can also save variables that is only available to a specific node, or flow or global.

So what you will do is, have the sun rise/set go to a function flow, then save whatever you looking for to the flow variable in a function node.

Then change your below horizon node to a function node, where you do an if statement based on the flow value with flow.get.

Edit:
So in short, above flow, whenever the switch state changes, I save it to the variable.
Whenever the temperature changes, I get the current switch state, then based on temp and switchstate and time, I do something if all align. If nothing is needed, I just return; which is equal to stop the flow right here.

Edit2:
Or use bigtimer node! https://flows.nodered.org/node/node-red-contrib-bigtimer
 
Last edited:

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
47,848
I did have a look at Bigtimer at first but it just seemed utter overkill for a basic on/off switch.

I see you send directly via MQTT whereas I interface with Home Assistant so that might make all the difference for running both on and off into a single node.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I did have a look at Bigtimer at first but it just seemed utter overkill for a basic on/off switch.

I see you send directly via MQTT whereas I interface with Home Assistant so that might make all the difference for running both on and off into a single node.
Yeah I try to keep Openhab and Node-RED as separate as I can, because I don't really want them to rely on each other. But for example the Xiaomi stuff is currently not in MQTT so that I have to grab from Openhab.
 

patrick123

Expert Member
Joined
Apr 10, 2005
Messages
2,894
Yeah I try to keep Openhab and Node-RED as separate as I can, because I don't really want them to rely on each other. But for example the Xiaomi stuff is currently not in MQTT so that I have to grab from Openhab.
I have gone the other route and integrate the 2 as much as possible.
The Change and the Switch nodes now allow you to set a Flow variable directly without having to resort to code.
Variables.PNG
And my Switch query:
Variables2.PNG
 

patrick123

Expert Member
Joined
Apr 10, 2005
Messages
2,894
Looking at all this makes me pleased that I just stuck to YAML.
That was my initial feeling, especially when my HA was on a Pi and everything just worked.
Unfortunately, I'm a tinkerer at heart and with my system becoming more and more evolving, it made sense to switch over to Node-red's graphical overview style which allows me at a glance to envisage the entire process, something that cannot be accomplished in YAML.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I agree, nothing wrong with YAML, but very few languages out there can beat nodejs when it comes to asynchronous parallel processing, which Node-RED is based on, which makes it one of the best solutions to have many automations happening at the same time.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
47,848
Looking at all this makes me pleased that I just stuck to YAML.

I do miss the ability to quickly check up on things or make changes from mobile.

Maybe there’s a Node Red app I don’t know about?
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
I do miss the ability to quickly check up on things or make changes from mobile.

Maybe there’s a Node Red app I don’t know about?
What specifically do you want to look up?

The nodered web interface do work on mobile, admittedly a bit cumbersome as you need to move things out of the way. But I do think you need to be more specific as to what you need. I still use openhab to see what the status of items are, and manually press buttons ect. Nodered is only for the automations, not my HA web interface.
 

calypso

Expert Member
Joined
Feb 10, 2009
Messages
1,857
I think the beauty is that one can use what they like. I have a small node-red sketch but that's where I left it.
I'm more a copy pasta kinda guy.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
47,848
What specifically do you want to look up?

The nodered web interface do work on mobile, admittedly a bit cumbersome as you need to move things out of the way. But I do think you need to be more specific as to what you need. I still use openhab to see what the status of items are, and manually press buttons ect. Nodered is only for the automations, not my HA web interface.

Seeing when Automations triggered is much easier inside the HA app for instance.

Turning them off is also super easy.

And making changes is nearly impossible on Node Red when mobile.

It’s not that it can’t be done on Node Red. HA just does it so much better.

Of course once it’s settled in I won’t have so much of a need to make changes, but the ability to turn on an off would be nice.

I often turn my presence based ones off if just walking in the neighbourhood because I’ve managed to activate it before going around the back of the house to a park.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
12,478
Seeing when Automations triggered is much easier inside the HA app for instance.

Turning them off is also super easy.

And making changes is nearly impossible on Node Red when mobile.

It’s not that it can’t be done on Node Red. HA just does it so much better.

Of course once it’s settled in I won’t have so much of a need to make changes, but the ability to turn on an off would be nice.

I often turn my presence based ones off if just walking in the neighbourhood because I’ve managed to activate it before going around the back of the house to a park.
ok so it sounds like thats one department where HA is better than both Node-RED and Openhab and me having no idea what HA look like, I think I don't understand it, and will only once I have used/played with HA.

That said, the idea of turning automations on and off easier, is something I also wanted, and I have been meaning to add state buttons in Openhab that is read by Nodered and use as a if statement to either go on with the flow or just stop at that point. That however is a lot of work, and repetitive for every thing you would have, so haven't had time or incentive.

Either way, totally agree with you on that, would love an easy on/off for each flow from mobile for Node-RED.
 

Doodler

Active Member
Joined
Jan 8, 2011
Messages
91
Anyone able to help. Trying to wire a sonoff T1 us light switch.

Had the switch working in my previous apartment no problem.

The new place however can’t seem to get it working.

When connected. The switch lights up. I can hear the switch activating and deactivating via the distinctive click noise, the wifi light flashes, yet when pressing switch the lightbulb does not come on.

At first I thought it was the bulb so I changed it to an led. The light then comes on, but has at a very low brightness and when activating the brightness only increases slightly. I can’t get it to turn off.

Any guidance?

Much appreciated.
 

Attachments

  • 63780B62-6F46-48B4-A67B-87109884451C.jpeg
    63780B62-6F46-48B4-A67B-87109884451C.jpeg
    771.5 KB · Views: 55

alqassam

Expert Member
Joined
Aug 11, 2014
Messages
4,112
Anyone able to help. Trying to wire a sonoff T1 us light switch.

Had the switch working in my previous apartment no problem.

The new place however can’t seem to get it working.

When connected. The switch lights up. I can hear the switch activating and deactivating via the distinctive click noise, the wifi light flashes, yet when pressing switch the lightbulb does not come on.

At first I thought it was the bulb so I changed it to an led. The light then comes on, but has at a very low brightness and when activating the brightness only increases slightly. I can’t get it to turn off.

Any guidance?

Much appreciated.
Where's your neutral?
 
Top