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 remove the device addr from json payload #10355

Merged
merged 3 commits into from
Jan 2, 2021

Conversation

jimmyw
Copy link

@jimmyw jimmyw commented Jan 1, 2021

Description:

Built on top of #10353 that should be merged first. Could not add this as a separate commit as it conflicts with previous pull request.

Zigbee: Remove the device addr from json payload, which can be used with zb_topic_fname where the addr is already known from the topic. Simplifies home assistant integration

Example:

21:56:18.664 CMD: SetOption119 0
21:56:18.670 MQT: stat/tasmota_E302DA/RESULT = {"SetOption119":"OFF"}
21:56:29.415 MQT: tele/tasmota_E302DA/1350/ZbReceived = {"0x1350":{"Device":"0x1350","Name":"Button_Mancave_Light","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":37}} 
21:56:38.364 CMD: SetOption119 1
21:56:38.370 MQT: stat/tasmota_E302DA/RESULT = {"SetOption119":"ON"}
21:56:41.246 MQT: tele/tasmota_E302DA/1350/ZbReceived = {"Device":"0x1350","Name":"Button_Mancave_Light","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":37} 

Homeassistant could be simplified this way

--- a/data/homeassistant/config/configuration.yaml
+++ b/data/homeassistant/config/configuration.yaml
@@ -150,8 +150,8 @@ sensor:
     name: "Guestroom Temperature"
     state_topic: "tele/tasmota_E302DA/3040/zbReceived"
     value_template: >
-      {%- if value_json['0x3040']['Temperature'] is defined -%}
-      {{ value_json['0x3040']['Temperature'] }}
+      {%- if value_json['Temperature'] is defined -%}
+      {{ value_json['Temperature'] }}
       {%- else -%}
       {{ states('sensor.guestroom_temperature') }}
       {%- endif -%}


Or just

--- a/data/homeassistant/config/configuration.yaml
+++ b/data/homeassistant/config/configuration.yaml
@@ -150,8 +150,8 @@ sensor:
     name: "Guestroom Temperature"
     state_topic: "tele/tasmota_E302DA/3040/zbReceived"
     value_template: >
-      {%- if value_json['0x3040']['Temperature'] is defined -%}
-      {{ value_json['0x3040']['Temperature'] }}
+      {{ value_json['Temperature'] }}
-      {%- else -%}
-      {{ states('sensor.guestroom_temperature') }}
-     {%- endif -%}


If its a sensor that just returns one value every time.

Related issue (if applicable): Builds on top of #10353

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

… message. This will make parsing simpler in homeassistant
…_topic_fname where the addr is already known from the topic
@arendst
Copy link
Owner

arendst commented Jan 2, 2021

@s-hadinger Agree?

@s-hadinger s-hadinger merged commit c9cce37 into arendst:development Jan 2, 2021
@hallard
Copy link
Contributor

hallard commented Feb 16, 2021

Sorry guys, just tried this awesome option118 but looks like my topic is not splitted, did I missed one other option before?

03:08:21.405 MQT: tele/zigbee2tasmota_040BC6/SENSOR = {"ZbReceived":{"0x4DDE":{"Device":"0x4DDE","Power":1,"Power2":0,"Endpoint":1,"LinkQuality":165}}}
03:08:32.012 CMD: setoption118 1
03:08:32.017 MQT: stat/zigbee2tasmota_040BC6/RESULT = {"SetOption118":"ON"}
03:08:34.039 MQT: tele/zigbee2tasmota_040BC6/SENSOR = {"0x4DDE":{"Device":"0x4DDE","Power":1,"Power2":0,"Endpoint":1,"LinkQuality":162}}
03:08:54.850 CMD: setoption119 1
03:08:54.855 MQT: stat/zigbee2tasmota_040BC6/RESULT = {"SetOption119":"ON"}
03:08:56.372 MQT: tele/zigbee2tasmota_040BC6/SENSOR = {"Device":"0x4DDE","Power":1,"Power2":0,"Endpoint":1,"LinkQuality":165}

@hallard
Copy link
Contributor

hallard commented Feb 16, 2021

Got it must SetOption89 1 before :-)

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

4 participants