Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to move ZbReceived from json into the mqtt subtopic. #10353

Closed
wants to merge 2 commits into from

Conversation

jimmyw
Copy link

@jimmyw jimmyw commented Jan 1, 2021

This will make parsing simpler in homeassistant.

Example:

21:30:49.178 MQT: tele/tasmota_E302DA/3D41/SENSOR = {"ZbReceived":{"0x3D41":{"Device":"0x3D41","Name":"Stair_Light","Dimmer":101,"Power":0,"Endpoint":1,"LinkQuality":29}}}
21:30:50.496 MQT: tele/tasmota_E302DA/B42F/SENSOR = {"ZbReceived":{"0xB42F":{"Device":"0xB42F","Name":"KitchenTable_Light","Power":0,"Dimmer":176,"Endpoint":1,"LinkQuality":21}}} (retained)
21:30:54.778 MQT: tele/tasmota_E302DA/3D41/SENSOR = {"ZbReceived":{"0x3D41":{"Device":"0x3D41","Name":"Stair_Light","Power":0,"Dimmer":101,"Endpoint":1,"LinkQuality":29}}}

21:30:55.345 CMD: SetOption118 1
21:30:55.350 MQT: stat/tasmota_E302DA/RESULT = {"SetOption118":"ON"}

21:31:01.641 MQT: tele/tasmota_E302DA/1350/ZbReceived = {"0x1350":{"Device":"0x1350","Name":"Button_Mancave_Light","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":29}}
21:32:42.788 MQT: tele/tasmota_E302DA/B3B1/ZbReceived = {"0xB3B1":{"Device":"0xB3B1","Name":"Temp_Mancave","Temperature":23.06,"Endpoint":1,"LinkQuality":26}}
21:32:50.825 MQT: tele/tasmota_E302DA/7EB5/ZbReceived = {"0x7EB5":{"Device":"0x7EB5","Name":"Temp_Livingroom","Humidity":30.83,"Endpoint":1,"LinkQuality":24}}
21:33:51.579 MQT: tele/tasmota_E302DA/F61C/ZbReceived = {"0xF61C":{"Device":"0xF61C","Name":"Temp_Spa","Temperature":21.69,"Endpoint":1,"LinkQuality":94}}

Example how this simplifies homeassistant:

diff --git a/data/homeassistant/config/configuration.yaml b/data/homeassistant/config/configuration.yaml
index e0a1748..4b7cf4b 100644
--- a/data/homeassistant/config/configuration.yaml
+++ b/data/homeassistant/config/configuration.yaml
@@ -148,10 +148,10 @@ sensor:
     device_class: humidity
   - platform: mqtt
     name: "Guestroom Temperature"
-    state_topic: "tele/tasmota_E302DA/3040/SENSOR"
+    state_topic: "tele/tasmota_E302DA/3040/ZbReceived"
     value_template: >
-      {%- if value_json.ZbReceived is defined and value_json.ZbReceived['0x3040'] is defined and value_json.ZbReceived['0x3040']['Temperature'] is defined -%}
-      {{ value_json.ZbReceived['0x3040']['Temperature'] }}
+      {%- if value_json['0x3040']['Temperature'] is defined -%}
+      {{ value_json['0x3040']['Temperature'] }}
       {%- else -%}
       {{ states('sensor.guestroom_temperature') }}
       {%- endif -%}

Description:

Related issue (if applicable): fixes #

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works on Tasmota core ESP8266 V.2.7.4.9
  • The code change is tested and works on Tasmota core ESP32 V.1.0.5-rc4
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@arendst
Copy link
Owner

arendst commented Jan 2, 2021

@s-hadinger Agree?

@s-hadinger
Copy link
Collaborator

Already included in #10355. Closing.

@s-hadinger s-hadinger closed this Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants