andrei-tatar / node-red-contrib-nora

Node Red Google Home integration
74 stars 25 forks source link

Great work - but a need clarification #4

Closed nosaj66au closed 5 years ago

nosaj66au commented 5 years ago

Hi Andrei, Thanks for the login all works well. I do understand this is the early stage of the project and development is on going. However is there any way to report back a change state from within Node Red? The use case is:

image

Any of the 3 switches can turn Mylight on or off via a on/off/toggle payload. My light feedback reports the current state. In this case the Physical Switch it does not required feedback however the dashboard switch and hopefully google switch need feed back to understand the present state.

Maybe I just need to look at this a different way?

Jason

andrei-tatar commented 5 years ago

I think it's fine... Here is how I have it setup: image The red node is the actual hardware switch. So each change (from switch/google/dashboard) is reported back to the others and vice versa.

nosaj66au commented 5 years ago

Cool I'll give it a go. I played around a bit but couldn't quit get the result I was after.Jaon 

Sent from my Samsung GALAXY S5

-------- Original message -------- From: Andrei Tatar notifications@github.com Date: 6/12/2018 10:18 PM (GMT+10:00) To: andrei-tatar/node-red-contrib-nora node-red-contrib-nora@noreply.github.com Cc: nosaj66au jason_sherwood@bigpond.com, Author author@noreply.github.com Subject: Re: [andrei-tatar/node-red-contrib-nora] Great work - but a need clarification (#4)

I think it's fine... Here is how I have it setup:

Km

The red node is the actual hardware switch. So each change (from switch/google/dashboard) is reported back to the others and vice versa.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/andrei-tatar/node-red-contrib-nora","title":"andrei-tatar/node-red-contrib-nora","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/andrei-tatar/node-red-contrib-nora"}},"updates":{"snippets":[{"icon":"PERSON","message":"@andrei-tatar in #4: I think it's fine... Here is how I have it setup:\r\nimage\r\nThe red node is the actual hardware switch. So each change (from switch/google/dashboard) is reported back to the others and vice versa. "}],"action":{"name":"View Issue","url":"https://github.com/andrei-tatar/node-red-contrib-nora/issues/4#issuecomment-444838132"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/andrei-tatar/node-red-contrib-nora/issues/4#issuecomment-444838132", "url": "https://github.com/andrei-tatar/node-red-contrib-nora/issues/4#issuecomment-444838132", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [andrei-tatar/node-red-contrib-nora] Great work - but a need clarification (#4)", "sections": [ { "text": "", "activityTitle": "Andrei Tatar", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@andrei-tatar", "facts": [

] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"andrei-tatar/node-red-contrib-nora\",\n\"issueId\": 4,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"andrei-tatar/node-red-contrib-nora\",\n\"issueId\": 4\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/andrei-tatar/node-red-contrib-nora/issues/4#issuecomment-444838132" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 421080697\n}" } ], "themeColor": "26292E" } ]

andrei-tatar commented 5 years ago

@nosaj66au Maybe you need to connect the Physical Switch output to the inputs of the dashboard and google home nodes.

impala454 commented 4 years ago

I realize this is closed but I am noticing a similar issue. I'm using an MQTT topic as a secondary "switch" to the nora light node. I can't really tie the two together the way @andrei-tatar did above as the MQTT output payload is different than the nora input payload. Thumbing through the code, it appears I simply need to send a JSON object to the nora node like this (this is actual output from my flow's debug):

{"payload":{"on":true}}

This gets sent to the input of the nora light node but my device in google home never updates. It does update when I toggle the light using the google home app though. Here is my flow:

nora_flow

The GetNoraPayload function node is just changing the message to match what the nora node is looking for. Code here:

on_off = msg.payload.value;

msg = {};
msg['payload'] = {};
msg.payload['on'] = on_off;

return msg;

Any help or thoughts appreciated. If this works out I'll definitely donate something to the cause!

sarreck commented 4 years ago

I have successfully deployed a working version of this.

The trick was converting the STRING from MQTT to a BOOLEAN state

image

There is a switch to output true/false then they are converted to the Boolean state. Same on the other end.

I am sure there is a more efficient way to do this, but it works.

impala454 commented 4 years ago

@sarreck can you show what you're doing in your switch and change nodes?

I have my MQTT topic input set to output a parsed JSON object, so it's definitely not outputting as a string. I verfied by debug the contents are::

{"time":1582090043840,"value":false}

I modified the GetNoraPayload function to make sure it's outputting what the nora light node needs and here's where it ended up:

on = false;

if (msg.payload.value === true) {
    on = true;
}

msg = {};
msg["payload"] = {};
msg.payload.on = on;

return msg;

I verified that output with debug here:

{"on":false}

Which is what the nora light node says it needs to update state.

sarreck commented 4 years ago

Switch image

Change image

impala454 commented 4 years ago

Thanks for this, it made me realize since it's a simple switch (not dimmable or colored) that I just needed to send the raw bool and not the full JSON string. I also noticed with the switch on the screen under google home it wasn't immediately updating, I just had to refresh it or back out to the previous screen, which is no big deal. Thanks!