Home Automation - Smartkit

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
Short of getting an RFID implant, it is very difficult to do presence detection on a child.
The best option is to watch her habits. Put a tilt sensor in her favourite doll, a motion sensor through her doorway, pressure sensor on her chair/bed, etc. Then define these as trackers for person X in Home Assistant so that the combined results define if she is home.
Ja ag that just takes it all too far and I'll just override stuff manully as the much simpler solution.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
It just does not discover. Do these have an indicator light?
Is it the only one you have? And the only point of reference?

Then I'm going to bet your neutral probably isn't a neutral and you have no power going to the thing.

Try hook it up to a simple plug with known wiring and make it work there first.
 

alqassam

Expert Member
Joined
Aug 11, 2014
Messages
2,687
Going to test on an extension cord later. The PM Shelley's do have a power indicator light
 

alqassam

Expert Member
Joined
Aug 11, 2014
Messages
2,687
Cant recall - don't think so.

Doesn't it show up as wifi ap?
Think it's that switches neutral hooked itnl up to another switch and it works.

But I'm having an issue with its functionality. One of the 2 way switches has to be on for Shelley to work.

This is my wiring diagram. Screenshot_20190718-141952_Samsung Notes.jpg20190718_140453.jpg
 

xrapidx

Honorary Master
Joined
Feb 16, 2007
Messages
36,557
Mine took forever to get fitted behind the light switch with a dimmer module in o
Think it's that switches neutral hooked itnl up to another switch and it works.

But I'm having an issue with its functionality. One of the 2 way switches has to be on for Shelley to work.

This is my wiring diagram. View attachment 685471View attachment 685473
I had that issue - something had to be switched around - have a look a couple of pages back,, I posted about it
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
Okay so one of the things I wanted to try Node-RED for was cleaning up my presence based alarm/gate/garage automations and I've been moderately successfull in doing so.

(Is there a better way to export this stuff? Or does a picture say a thousand words)



Now my problem is that because I walk the kids to school in the morning I had duplicate automations in HA that only triggered before 09:00 with a 40 second delay and then two more that triggered after 09:00 without it.

How the hell do I incorporate time into this logic so I can add the 40 second delay in the stream?

Logically it's as simple as a switch but I'm specifically stuck on the "before 9" and "after 9" conditions.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
Okay seems the node-red-contrib-time-range-switch was the answer.



Nice thing now, and what I was hoping for is that I can stop the entire automation from happening should the state change inside those 40 seconds.

This wasn't possible with Home Assistant as the delays only work after the trigger so if someone was impatient (in the car on said morning) and pressed the buttons to open stuff meanwhile then it would trigger it again and you'd have a door closing which was open but HA believes it was closed since it checked and actioned 40 seconds before.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
Now on to a different problem I have.

For some reason only when the Docker is updated does my Alarm State get lost and changes to Unknown so these automations in the previous post obviously don't work until the buttons are pressed to update those states or they are manually overridden.

Now the interesting part is that this never happens with the Front Gate...but that is using the "normal" states of open closed in their normal expected positions.

It used to happen with the garage door which is inverted because the switch is on the "open" side but I fixed that somehow at some point.

The alarm uses completely custom state topics of disarmed or armed_away.

My switch retain and power retain things are correct as per every guide and I've even put the Tasmota automation in to send a blank MQTT message for it to update but this just doesn't work. (but did fix the garage that had the same behaviour at one point).

So is there any way to set the state of something (as one can do manually in the interface) with an automation and code logic without actually sending a trigger command?

******

Okay this is a weird one but I managed to fix it by actually turning Switchretain OFF, flipping the actual switch (well via MQTT) and then turning it back ON again and now it keeps it's state.

So something to do with Tasmota and the way it updates that retained message to flush it out and not a HA issue at all.
 
Last edited:

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
I'm still deeply confused how Node Red doesn't have something as simple as the basic time to us as an event condition.

What I mean is one that isn't the single Input of a flow but can be put in line of another input.

I thought the time-range-switch was the answer but the problem is that it does too much when out of the zone and puts everything off the whole time.

I want to simply do...

Presence (Binary Sensor) > Time > Turn On
Presence (Binary Sensor) > Time > Turn Off

Instead, I'm now basically doing the same as I did in HA which is...

Presence > Time > Turn On > Delay > Turn Off.


The delay works in a perfect world if I got home at exactly 19:00 or before and wanted it off at 23:00.

But now if I say get home at 20:00 and it detects the presence change now the off will run an hour later.
 

Tinuva

The Magician
Joined
Feb 10, 2005
Messages
8,601
I'm still deeply confused how Node Red doesn't have something as simple as the basic time to us as an event condition.

What I mean is one that isn't the single Input of a flow but can be put in line of another input.

I thought the time-range-switch was the answer but the problem is that it does too much when out of the zone and puts everything off the whole time.

I want to simply do...

Presence (Binary Sensor) > Time > Turn On
Presence (Binary Sensor) > Time > Turn Off

Instead, I'm now basically doing the same as I did in HA which is...

Presence > Time > Turn On > Delay > Turn Off.


The delay works in a perfect world if I got home at exactly 19:00 or before and wanted it off at 23:00.

But now if I say get home at 20:00 and it detects the presence change now the off will run an hour later.
You could do that in a function with minimal code, if the goal is to have less nodes in the flow.
 

patrick123

Expert Member
Joined
Apr 10, 2005
Messages
2,353
Okay seems the node-red-contrib-time-range-switch was the answer.



Nice thing now, and what I was hoping for is that I can stop the entire automation from happening should the state change inside those 40 seconds.

This wasn't possible with Home Assistant as the delays only work after the trigger so if someone was impatient (in the car on said morning) and pressed the buttons to open stuff meanwhile then it would trigger it again and you'd have a door closing which was open but HA believes it was closed since it checked and actioned 40 seconds before.
You have the capability of setting a variable for the context of the entire flow.:

JavaScript:
var count=flow.get('count') || 0;  // get variable

flow.set('count',count); // set the variable
Thus you can have a second flow that looks for an event and sets this variable.
After you delay, simply check this variable value and abort if required.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
You have the capability of setting a variable for the context of the entire flow.:

JavaScript:
var count=flow.get('count') || 0;  // get variable

flow.set('count',count); // set the variable
Thus you can have a second flow that looks for an event and sets this variable.
After you delay, simply check this variable value and abort if required.
You have completely lost me in one single seemingly simple post.

That Flow is the one that actually works exactly as I would like it to, everything else is still a cock up.
 

patrick123

Expert Member
Joined
Apr 10, 2005
Messages
2,353
I'm still deeply confused how Node Red doesn't have something as simple as the basic time to us as an event condition.

What I mean is one that isn't the single Input of a flow but can be put in line of another input.

I thought the time-range-switch was the answer but the problem is that it does too much when out of the zone and puts everything off the whole time.

I want to simply do...

Presence (Binary Sensor) > Time > Turn On
Presence (Binary Sensor) > Time > Turn Off

Instead, I'm now basically doing the same as I did in HA which is...

Presence > Time > Turn On > Delay > Turn Off.


The delay works in a perfect world if I got home at exactly 19:00 or before and wanted it off at 23:00.

But now if I say get home at 20:00 and it detects the presence change now the off will run an hour later.
Simply add an Inject node to joined at the call off service set the time trigger to 23:00 and it will switch it off immaterial if the delay has been reached or not yet.
 

patrick123

Expert Member
Joined
Apr 10, 2005
Messages
2,353
You have completely lost me in one single seemingly simple post.

That Flow is the one that actually works exactly as I would like it to, everything else is still a cock up.
This is a simplified diagram:
flow01.PNG

Create a new flow sheet, copy this code and import it onto the sheet for your perusal.

JSON:
[
    {
        "id": "7d34e824.449118",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b1c69f1f.00145",
        "type": "server-state-changed",
        "z": "7d34e824.449118",
        "name": "Door Opened",
        "server": "378bb7a2.0cc518",
        "version": 1,
        "entityidfilter": "",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "open",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 176.5,
        "y": 134,
        "wires": [
            [
                "494a41e3.a5a67"
            ],
            []
        ]
    },
    {
        "id": "494a41e3.a5a67",
        "type": "function",
        "z": "7d34e824.449118",
        "name": "flow.set('opened',true); // set the variable",
        "func": "flow.set('opened',true); // set the variable\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 546.5,
        "y": 133,
        "wires": [
            []
        ]
    },
    {
        "id": "75be8c15.448914",
        "type": "server-state-changed",
        "z": "7d34e824.449118",
        "name": "Arm Alarm",
        "server": "378bb7a2.0cc518",
        "version": 1,
        "entityidfilter": "",
        "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": 146.5,
        "y": 283,
        "wires": [
            [
                "95bd2d59.e7905"
            ],
            []
        ]
    },
    {
        "id": "95bd2d59.e7905",
        "type": "function",
        "z": "7d34e824.449118",
        "name": "flow.set('opened',false); // set the variable",
        "func": "flow.set('opened',false); // set the variable\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 410.5,
        "y": 281,
        "wires": [
            [
                "9978c76b.ad8188"
            ]
        ]
    },
    {
        "id": "9978c76b.ad8188",
        "type": "delay",
        "z": "7d34e824.449118",
        "name": "",
        "pauseType": "delay",
        "timeout": "35",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 364.5,
        "y": 472,
        "wires": [
            [
                "b9f06c47.8c07d"
            ]
        ]
    },
    {
        "id": "b9f06c47.8c07d",
        "type": "switch",
        "z": "7d34e824.449118",
        "name": "Was anything opened - expression: flow.get('opened') = false",
        "property": "flow.get('opened')",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 748.5,
        "y": 437,
        "wires": [
            [
                "8372fd95.ab038"
            ]
        ]
    },
    {
        "id": "8372fd95.ab038",
        "type": "debug",
        "z": "7d34e824.449118",
        "name": "Arm Alarm",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1112.5,
        "y": 417,
        "wires": []
    },
    {
        "id": "378bb7a2.0cc518",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "hassio": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]
It's nothing workable, but to give you an idea how 2 different flows can interact with the same variable.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
This is a simplified diagram:
View attachment 686897

Create a new flow sheet, copy this code and import it onto the sheet for your perusal.

JSON:
[
    {
        "id": "7d34e824.449118",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "b1c69f1f.00145",
        "type": "server-state-changed",
        "z": "7d34e824.449118",
        "name": "Door Opened",
        "server": "378bb7a2.0cc518",
        "version": 1,
        "entityidfilter": "",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "open",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "x": 176.5,
        "y": 134,
        "wires": [
            [
                "494a41e3.a5a67"
            ],
            []
        ]
    },
    {
        "id": "494a41e3.a5a67",
        "type": "function",
        "z": "7d34e824.449118",
        "name": "flow.set('opened',true); // set the variable",
        "func": "flow.set('opened',true); // set the variable\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 546.5,
        "y": 133,
        "wires": [
            []
        ]
    },
    {
        "id": "75be8c15.448914",
        "type": "server-state-changed",
        "z": "7d34e824.449118",
        "name": "Arm Alarm",
        "server": "378bb7a2.0cc518",
        "version": 1,
        "entityidfilter": "",
        "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": 146.5,
        "y": 283,
        "wires": [
            [
                "95bd2d59.e7905"
            ],
            []
        ]
    },
    {
        "id": "95bd2d59.e7905",
        "type": "function",
        "z": "7d34e824.449118",
        "name": "flow.set('opened',false); // set the variable",
        "func": "flow.set('opened',false); // set the variable\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 410.5,
        "y": 281,
        "wires": [
            [
                "9978c76b.ad8188"
            ]
        ]
    },
    {
        "id": "9978c76b.ad8188",
        "type": "delay",
        "z": "7d34e824.449118",
        "name": "",
        "pauseType": "delay",
        "timeout": "35",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 364.5,
        "y": 472,
        "wires": [
            [
                "b9f06c47.8c07d"
            ]
        ]
    },
    {
        "id": "b9f06c47.8c07d",
        "type": "switch",
        "z": "7d34e824.449118",
        "name": "Was anything opened - expression: flow.get('opened') = false",
        "property": "flow.get('opened')",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 748.5,
        "y": 437,
        "wires": [
            [
                "8372fd95.ab038"
            ]
        ]
    },
    {
        "id": "8372fd95.ab038",
        "type": "debug",
        "z": "7d34e824.449118",
        "name": "Arm Alarm",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1112.5,
        "y": 417,
        "wires": []
    },
    {
        "id": "378bb7a2.0cc518",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "hassio": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]
It's nothing workable, but to give you an idea how 2 different flows can interact with the same variable.
Thanks but that all seems unnecessarily complex to achieve exactly the same thing.

And I prefer working with things I actually understand.
 

SauRoNZA

Honorary Master
Joined
Jul 6, 2010
Messages
33,333
Simply add an Inject node to joined at the call off service set the time trigger to 23:00 and it will switch it off immaterial if the delay has been reached or not yet.
Aaah didn't think of it like that, I just made a separate workflow for the switch off task but this makes a lot more sense since I simply forgot the concept of multiple inputs.

That will do nicely to keep it streamlined.
 
Top