Where do the json_attributes go? Topic is solved
Moderator: leecollings
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Where do the json_attributes go?
Hi
I've connected Domoticz to MQTT Autodiscovery OK and it detects my device config and adds it, but where do the device attributes configured by the json_attributes_topic go? How can I access these from scripts or add them to the dashboard? Should I modify the device MQTT processing to configure each of the 32 sensors with its own homeassistant/sensor/NAME/config?
Thanks for any help!
I've connected Domoticz to MQTT Autodiscovery OK and it detects my device config and adds it, but where do the device attributes configured by the json_attributes_topic go? How can I access these from scripts or add them to the dashboard? Should I modify the device MQTT processing to configure each of the 32 sensors with its own homeassistant/sensor/NAME/config?
Thanks for any help!
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
I have no clue what you are asking us. I do not use MQTT so that will also not help.
Please add an example what kind of attributes and function you want to get.
Please add an example what kind of attributes and function you want to get.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
I will try to explain further. You may not have used MQTT but I've not used Domoticz before so I may be using terms incorrectly or meanings from another system, so please excuse/question any confusion.
The MQTT autodiscovery is described in https://www.domoticz.com/wiki/MQTT#Add_ ... Gateway.22
My device controller publishes the following configuration info to a homeassistant/climate/melcloud/config topic message:
Domoticz creates three devices in response: a thermostat, a mode switch and a temperature sensor, which are then populated from MQTT messages.
But there are a lot (32 I think) of other sensors in the json of melcloud/status/values and the temperatures are correctly extracted (which means that melcloud/status/values messages are being read and decoded to apply the above templates), but "json_attributes_topic":"melcloud/status/values" should result in them all becoming device attributes (not sure on which of the three devices) but I haven't found them anywhere. I'm not even sure how to see device attributes in Domoticz.
There's no errors logged. Are they going somewhere, or being discarded?
(In case it matters, the reason the MELCloud data is sent over MQTT is that it's used by other software too, including OpenEnergyMonitor, and MELCloud is rate-limited so using a native MELCloud plugin for each software results in unreliability and some Very Bad Things happening. Oh, and MELCloud does really some surprising things sometimes, so it's nice to have just the connector isolated to limit crash damage.)
The MQTT autodiscovery is described in https://www.domoticz.com/wiki/MQTT#Add_ ... Gateway.22
My device controller publishes the following configuration info to a homeassistant/climate/melcloud/config topic message:
Code: Select all
{
"name":"MELCloud MQTT",
"unique_id":"7bbe1d741e15fa45bf202efc1b8fc7e0",
"modes":["off","heat","auto"],
"mode_command_topic":"melcloud/control/mode",
"mode_state_topic":"melcloud/status/mode",
"json_attributes_topic":"melcloud/status/values",
"precision":"0.5",
"temperature_command_topic":"melcloud/control/temperature",
"temperature_state_topic":"melcloud/status/values",
"temperature_state_template":"{{ value_json.TargetHCTemperatureZone1 }}",
"current_temperature_topic":"melcloud/status/values",
"current_temperature_template":"{{ value_json.RoomTemperatureZone1 }}",
"action_topic":"melcloud/status/action"
}
But there are a lot (32 I think) of other sensors in the json of melcloud/status/values and the temperatures are correctly extracted (which means that melcloud/status/values messages are being read and decoded to apply the above templates), but "json_attributes_topic":"melcloud/status/values" should result in them all becoming device attributes (not sure on which of the three devices) but I haven't found them anywhere. I'm not even sure how to see device attributes in Domoticz.
There's no errors logged. Are they going somewhere, or being discarded?
(In case it matters, the reason the MELCloud data is sent over MQTT is that it's used by other software too, including OpenEnergyMonitor, and MELCloud is rate-limited so using a native MELCloud plugin for each software results in unreliability and some Very Bad Things happening. Oh, and MELCloud does really some surprising things sometimes, so it's nice to have just the connector isolated to limit crash damage.)
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
I think it depends on the config topics that triggers device creation in Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
If they are being recorded, how could I see the device attributes in Domoticz?
Edit to add: https://github.com/domoticz/domoticz/bl ... scover.cpp seems to do something with it, but possibly only if there's also a json_attributes_template so I've added a null one ( {{ value_json }} ) to the config message. At a quick glance without stepping through the code and understanding the data structures, it looks like maybe the attributes would be stored as a string on the temperature sensor but I've no idea how to access it.
Edit to add: https://github.com/domoticz/domoticz/bl ... scover.cpp seems to do something with it, but possibly only if there's also a json_attributes_template so I've added a null one ( {{ value_json }} ) to the config message. At a quick glance without stepping through the code and understanding the data structures, it looks like maybe the attributes would be stored as a string on the temperature sensor but I've no idea how to access it.
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
If I interpreted it right the attributes will be published in the melcloud/values/status topic. I suppose they will be ignored if not appropriate (if they cannot be linked to a device attribute known in Domoticz). Battery status for example is something Domoticz knows and will be used as battery status (but not logged)
What kind of attributes are being published in melcloud/values/status that you want to see but not shown in the domoticz device log (button log)? See wiki https://www.domoticz.com/wiki/Managing_ ... Device_Log
What kind of attributes are being published in melcloud/values/status that you want to see but not shown in the domoticz device log (button log)? See wiki https://www.domoticz.com/wiki/Managing_ ... Device_Log
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
Here's a sample of melcloud/values/status. It would be nice to see most of them, but the OutdoorTemperature* and CurrentEnergy* values are possibly the most useful ones not currently visible:waltervl wrote: ↑Wednesday 05 October 2022 17:01 What kind of attributes are being published in melcloud/values/status that you want to see but not shown in the domoticz device log (button log)? See wiki https://www.domoticz.com/wiki/Managing_ ... Device_Log
{"OutdoorTemperature":13.0,"OutdoorTemperatureForecast1":15,"OutdoorTemperatureForecast2":9,"RoomTemperatureZone1":21.0,"EcoHotWater":1.0,"WaterPump1Status":0.0,"WaterPump2Status":0.0,"WaterPump3Status":0.0,"WaterPump4Status":0.0,"SetTankWaterTemperature":49.0,"TankWaterTemperature":48.5,"OperationMode":0.0,"DefrostMode":0.0,"FlowTemperature":23.0,"ReturnTemperature":22.5,"CurrentEnergyConsumed":1.0,"CurrentEnergyProduced":0.0,"DemandPercentage":100.0,"HeatPumpFrequency":0.0,"DailyHeatingEnergyConsumed":1.85,"DailyHeatingEnergyProduced":6.97,"HeatingEnergyConsumedRate1":0.0,"HeatingEnergyProducedRate1":0.0,"HotWaterEnergyConsumedRate1":1.0,"HotWaterEnergyProducedRate1":0.0,"HeatingEnergyConsumedRate2":0.0,"HeatingEnergyProducedRate2":0.0,"HotWaterEnergyConsumedRate2":0.0,"HotWaterEnergyProducedRate2":0.0,"DailyHotWaterEnergyConsumed":2.62,"DailyHotWaterEnergyProduced":8.7,"TargetHCTemperatureZone1":17.0,"SetHeatFlowTemperatureZone1":37.0}
As I mentioned at the top, I'll configure more devices if needed, but it really seems like this should be captured already by the climate devices and available to scripts somehow. MQTTAutoDiscovery.cpp seems to do something with it but I don't know how to access the state_topic values. My first attempt to try a python script resulted in a crashed/won't-restart Domoticz but I see in github issues that the python template script in 2022.1 is buggy.
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
I think the Autodiscovery protocol is not followed correctly by melcloud. All those attributes should be linked to a device in the config topic.
What interface is behind this, what application is creating those mqtt statements? Zigbee2mqtt? Zwave2mqtt?
Edit: there is also a python plugin for melcloud: https://github.com/gysmo38/domoticz-python-melcloud
You need to be on Buster OS (not bullseye) or latest domoticz beta to use it
What interface is behind this, what application is creating those mqtt statements? Zigbee2mqtt? Zwave2mqtt?
Edit: there is also a python plugin for melcloud: https://github.com/gysmo38/domoticz-python-melcloud
You need to be on Buster OS (not bullseye) or latest domoticz beta to use it
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
Aren't all those attributes are linked to the climate device in the config topic? It looks correct to me according to https://www.home-assistant.io/integrati ... mate.mqtt/ and the linked example from sensor.mqtt. Maybe I should install homeassistant to see how it reacts to the config.
It's a melcloud-MQTT bridge in python that I wrote last winter. I'll publish it somewhere once the local specifics are removed.What interface is behind this, what application is creating those mqtt statements? Zigbee2mqtt? Zwave2mqtt?
Thanks: I'd only seen the shell one. Reading through, I'm fairly sure that python plugin only works for air-to-air devices (I have air-to-water) and I need the data on MQTT for other uses as explained, so I don't think it helps me.Edit: there is also a python plugin for melcloud: https://github.com/gysmo38/domoticz-python-melcloud
You need to be on Buster OS (not bullseye) or latest domoticz beta to use it
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
Domoticz devices/sensors normally only log one attribute except for some combined devices (eg temp/humidity/barometer).
So for each to be logged attribute a device has to be created.
For a list of devices and what they log see the wiki https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors
I think you have to extend your config topic with the desired extra devices ( but no expert on MQTT Autodiscover at all!)
So for each to be logged attribute a device has to be created.
For a list of devices and what they log see the wiki https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors
I think you have to extend your config topic with the desired extra devices ( but no expert on MQTT Autodiscover at all!)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
So, I installed homeassistant and it stores all the attributes on the climate control device (equivalent to domoticz's thermostat setpoint device) but they can only be seen in the Developer Tools unless you write some code to put them somewhere else. The main change resulting from that testing has been adding a device block to the autodiscovery config, to group all the sensors and controls together as being "entities" from the same "device" in homeassistant-speak. That's something I think domoticz already got right, using the same ID field for the three devices it created.mjray wrote: ↑Wednesday 05 October 2022 20:12Aren't all those attributes are linked to the climate device in the config topic? It looks correct to me according to https://www.home-assistant.io/integrati ... mate.mqtt/ and the linked example from sensor.mqtt. Maybe I should install homeassistant to see how it reacts to the config.
I'll add an option to the bridge software to create 30+ individual sensors, as waltervl suggested. I think it will make the displays look a bit of a mess by default, but all the data will be easily accessible!
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Where do the json_attributes go?
You can disable the devices in the device list (menu setup devices) if you don't want to see them in one of the devices tabs. From the device list you can still see the logged values if you click on the log icon.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 05 October 2022 2:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Contact:
Re: Where do the json_attributes go?
Just to finish this off: I've published the melcloud-mqtt bridge at https://github.com/mjray/melcloud-mqtt.py and my Domoticz event script (triggering on Device changes) is this
Code: Select all
import DomoticzEvents as DE
if ((DE.Devices["Pause Heating Decisions"].n_value == 0)
and ((DE.changed_device.name == "Thermostat")
or (DE.changed_device.name == "RoomTemperatureZone1"))):
control = "Central Heating"
cmode = DE.Devices["MELCloud MQTT"].n_value
current = float(DE.Devices["RoomTemperatureZone1"].s_value)
setpoint = float(DE.Devices["Thermostat"].s_value)
margin = float(DE.user_variables["hysteresis"])
neverheatover = float(DE.user_variables["heating_off_degC"])
Tout = float(DE.Devices["OutdoorTemperature"].s_value)
Toutnext = float(DE.Devices["OutdoorTemperatureForecast1"].s_value)
Toutfutr = float(DE.Devices["OutdoorTemperatureForecast2"].s_value)
warming = ((Tout < Toutnext) and (Toutnext < Toutfutr))
cooling = ((Tout > Toutnext) and (Toutnext > Toutfutr))
adj = 0
if float(DE.Devices["OperationMode"].s_value) == 1.0:
adj += -0.5
if warming:
adj += +0.5
elif cooling:
adj += -0.5
decision = "is %s + %s in %s ± %s? Current mode %s" % (current, adj, setpoint, margin, cmode)
DE.Log("Heating Control: %s" % decision)
if ((Tout < neverheatover)
and ((current + adj) <= (setpoint -margin))
and (cmode < 2)):
DE.Log("Heating Control: on")
DE.Command(control, "On")
DE.Command("Variable:last-heating-change", decision)
elif (((current + adj) > (setpoint +margin))
and (cmode > 0)):
DE.Log("Heating Control: off")
DE.Command(control, "Off")
DE.Command("Variable:last-heating-change", decision)
Who is online
Users browsing this forum: No registered users and 0 guests