mikejac/node-red-contrib-google-smarthome

Device type light write back

Closed this issue · 8 comments

T1mey commented

Hello,

one question about how to inform the google device about a manual change on a device.
I my case a dimmer.

So if I turn it on or off or change the brightness I get a value of the brightness.

msg.payload : number
1

So how do I write this information back to the device ? Same payload as if it's triggered von google home app ?

T1mey commented

Tried now with

image

Leads to that

{"brightness":0,"on":false,"online":true}

But this is not updating the device (and not the values in google home app)

Hi @T1mey,

Can you inform in which way Node Red receives the data.
How does the received message look.

In my case, I receive the data from a Shelly Dimmer 2.
If I activate the dimmer the MQTT receives the following data:

ison: true source: "http" has_timer: false timer_started: 0 timer_duration: 0 timer_remaining: 0 mode: "white" brightness: 20 transition: 0

If I switch the dimmer off:

ison: false source: "http" has_timer: false timer_started: 0 timer_duration: 0 timer_remaining: 0 mode: "white" brightness: 20 transition: 0

In this case the intersting payloads are:
msg.payload.ison (true|false)
msg.payload.brightness

But this will depend on your device. What do you receive? From what type of device (dimmer)?

The above data is sent to a "Function" node, which has the following contents:

if (msg.payload.ison === true) { msg.payload = { "brightness": msg.payload.brightness, "on": true, "online": true } } else if (msg.payload.ison === false) { msg.payload = { "on": false, "online": true } } return msg;

This works for me and the Google Dimmer node will receive that message.

Regards

One Remark.

It is probably better to raise such a question on the Node-RED forum page instead of Github in the future.
https://discourse.nodered.org/
There is a lot of support on all issues.

T1mey commented

My device is a homematic dimmer.

So I receive from the google node:

{"online":true,"brightness":74,"on":true}

Then I scale the brightness and send it to my device. This is working well

image

I I turn off the dimmer I receive

msg.payload : number
1

and transform that payload back to the format I received ....

Hello @T1mey,

As I understand correctly, you receive, if you switch off the dimmer, only msg.payload (number:1).

Looks strange to receive a 1, in case you switch off the device.
But okay.

In that case I would send something like:

if (msg.payload === 1) { msg.payload = { "on": false, "online": true } } return msg;

As you said that it is a Homematic device, I suggest you take a look at:

https://flows.nodered.org/node/node-red-contrib-homematic and at:
https://github.com/firsttris/node-red-contrib-homematic

Or:

https://flows.nodered.org/node/node-red-contrib-ccu

Regards

T1mey commented

I tried now a hardcoded json object but wit no effect.
So I don't think it's a node-red-contrib-homematic probem. It's more a problem of node-red-contrib-google-smarthome?

image

Another thing.... Should this be green ?

image

Another thing.... Should this be green ?

No, it shouldn't. This is always yellow.


I'm not sure if I understand your problem.

So you are sending in messages into the Google device node, but neither the status message on the node nor the Google Home app is updated?

image

It also doesn't work if you inject hardcoded data like in this example?

[{"id":"1bdf3845c56317ef","type":"google-device","z":"ba4ea2f93145cb4f","client":"","name":"Testlampe","nicknames":"","topic":"","room_hint":"","device_type":"LIGHT","trait_appselector":false,"trait_channel":false,"trait_inputselector":false,"trait_mediastate":false,"trait_onoff":true,"trait_transportcontrol":false,"trait_modes":false,"trait_volume":false,"trait_toggles":false,"trait_brightness":true,"trait_colorsetting":false,"appselector_file":"applications_<id>.json","appselector_type":"str","channel_file":"channels_<id>.json","channel_type":"str","inputselector_file":"inputs_<id>.json","inputselector_type":"str","command_only_input_selector":false,"ordered_inputs":false,"support_activity_state":false,"support_playback_state":false,"command_query_onoff":"","supported_commands":["CAPTION_CONTROL","NEXT","PAUSE","PREVIOUS","RESUME","SEEK_RELATIVE","SEEK_TO_POSITION","SET_REPEAT","SHUFFLE","STOP"],"volume_max_level":100,"volume_can_mute_and_unmute":true,"volume_default_percentage":40,"level_step_size":1,"command_only_volume":false,"command_only_brightness":false,"command_only_colorsetting":false,"color_model":"temp","temperature_min_k":2000,"temperature_max_k":9000,"modes_file":"modes_<id>.json","modes_type":"str","command_query_modes":"","toggles_file":"toggles_<id>.json","toggles_type":"str","command_query_toggles":"","trait_camerastream":false,"hls":"","hls_app_id":"","dash":"","dash_app_id":"","smooth_stream":"","smooth_stream_app_id":"","progressive_mp4":"","progressive_mp4_app_id":"","webrtc":"","webrtc_offer":"","webrtc_ice_servers":"","webrtc_ice_servers_type":"str","auth_token":"","topic_filter":false,"passthru":false,"persistent_state":false,"trait_scene":false,"scene_reversible":true,"trait_timer":false,"trait_temperaturesetting":false,"max_timer_limit_sec":86400,"command_only_timer":false,"available_thermostat_modes":["off","heat","cool","on","heatcool","auto","fan-only","purifier","eco","dry"],"min_threshold_celsius":0,"max_threshold_celsius":40,"thermostat_temperature_unit":"C","buffer_range_celsius":2,"command_query_temperaturesetting":"","trait_temperaturecontrol":false,"tc_min_threshold_celsius":0,"tc_max_threshold_celsius":40,"tc_temperature_step_celsius":1,"tc_temperature_unit_for_ux":"C","tc_command_query_temperaturecontrol":"","trait_humiditysetting":false,"min_percent":0,"max_percent":100,"command_query_humiditysetting":"","trait_dock":false,"trait_locator":false,"trait_lockunlock":false,"trait_reboot":false,"trait_openclose":false,"discrete_only_openclose":false,"open_direction":[],"command_query_openclose":"","trait_startstop":false,"pausable":false,"available_zones":[],"trait_runcycle":false,"trait_softwareupdate":false,"trait_rotation":false,"supports_degrees":true,"supports_percent":true,"rotation_degrees_min":0,"rotation_degrees_max":360,"supports_continuous_rotation":false,"command_only_rotation":false,"trait_lighteffects":false,"default_sleep_duration":1800,"default_wake_duration":1800,"supported_effects":["colorLoop","sleep","wake"],"trait_statusreport":false,"trait_cook":false,"supported_cooking_modes":[],"food_presets_file":"foodPresets_<id>.json","food_presets_type":"str","trait_fanspeed":false,"reversible":false,"supports_fan_speed_percent":false,"fan_speeds_ordered":false,"command_only_fanspeed":false,"available_fan_speeds_file":"availableFanSpeeds_<id>.json","available_fan_speeds_type":"str","trait_sensorstate":false,"sensor_states_supported":[],"arm_levels_ordered":false,"trait_fill":false,"available_fill_levels_file":"availableFillLevels_<id>.json","available_fill_levels_type":"str","supports_fill_percent":false,"ordered_fill_levels":true,"trait_armdisarm":false,"available_arm_levels_file":"availableArmLevels_<id>.json","available_arm_levels_type":"str","trait_energystorage":false,"is_rechargeable":false,"query_only_energy_storage":false,"energy_storage_distance_unit_for_ux":"","trait_dispense":false,"supported_dispense_items_file":"supportedDispenseItems_<id>.json","supported_dispense_items_type":"str","supported_dispense_presets_file":"supportedDispensePresets_<id>.json","supported_dispense_presets_type":"str","trait_networkcontrol":false,"supports_enabling_guest_network":false,"supports_disabling_guest_network":false,"supports_getting_guest_network_password":false,"network_profiles":[],"supports_enabling_network_profile":false,"supports_disabling_network_profile":false,"supports_network_download_speedtest":false,"supports_network_upload_speedtest":false,"trait_objectdetection":false,"show_trait":"selected","advanced_settings":true,"ct_appselector":"","ct_armdisarm":"","ct_brightness":"","ct_camerastream":"","ct_channel":"","ct_colorsetting":"","ct_cook":"","ct_dispense":"","ct_dock":"","ct_energystorage":"","ct_fanspeed":"","ct_fill":"","ct_humiditysetting":"","ct_inputselector":"","ct_lighteffects":"","ct_locator":"","ct_lockunlock":"","ct_mediastate":"","ct_modes":"","ct_networkcontrol":"","ct_objectdetection":"","ct_onoff":"","ct_openclose":"","ct_reboot":"","ct_rotation":"","ct_runcycle":"","ct_scene":"","ct_sensorstate":"","ct_softwareupdate":"","ct_startstop":"","ct_statusreport":"","ct_temperaturecontrol":"","ct_temperaturesetting":"","ct_timer":"","ct_toggles":"","ct_transportcontrol":"","ct_volume":"","pin_appselector":"","pin_armdisarm":"","pin_brightness":"","pin_camerastream":"","pin_channel":"","pin_colorsetting":"","pin_cook":"","pin_dispense":"","pin_dock":"","pin_energystorage":"","pin_fanspeed":"","pin_fill":"","pin_humiditysetting":"","pin_inputselector":"","pin_lighteffects":"","pin_locator":"","pin_lockunlock":"","pin_mediastate":"","pin_modes":"","pin_networkcontrol":"","pin_objectdetection":"","pin_onoff":"","pin_openclose":"","pin_reboot":"","pin_rotation":"","pin_runcycle":"","pin_scene":"","pin_sensorstate":"","pin_softwareupdate":"","pin_startstop":"","pin_statusreport":"","pin_temperaturecontrol":"","pin_temperaturesetting":"","pin_timer":"","pin_toggles":"","pin_transportcontrol":"","pin_volume":"","x":580,"y":780,"wires":[[]]},{"id":"8b50e14c2fef623d","type":"inject","z":"ba4ea2f93145cb4f","name":"Aus","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"brightness\":0,\"on\":false,\"online\":true}","payloadType":"json","x":310,"y":700,"wires":[["1bdf3845c56317ef"]]},{"id":"a02770dca244c4c7","type":"inject","z":"ba4ea2f93145cb4f","name":"An 50","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"brightness\":50,\"on\":true,\"online\":true}","payloadType":"json","x":310,"y":780,"wires":[["1bdf3845c56317ef"]]},{"id":"a5cfcb608ed5d172","type":"inject","z":"ba4ea2f93145cb4f","name":"An 100","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"brightness\":100,\"on\":true,\"online\":true}","payloadType":"json","x":310,"y":820,"wires":[["1bdf3845c56317ef"]]},{"id":"d58c62aaf289d268","type":"inject","z":"ba4ea2f93145cb4f","name":"Aus 50","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"brightness\":50,\"on\":false,\"online\":true}","payloadType":"json","x":310,"y":740,"wires":[["1bdf3845c56317ef"]]}]

Do you see any messages in Node-RED's debug panel?

image

T1mey commented

I found my failure ... had the checkbox "Filter incoming messages by topic" checked ...

Thanks 2 all ...

I'm glad you got it fixed.