I have dual DHT22 sensors connected to a D1 Mini, one gathering temperature & humidity within my greenhouse and the other measuring temperature & humidity outside the greenhouse. The D1 mini is running Tasmota and the data for both sensors is published as a single topic as follows:
i.e no -04 or -05 after the AM2301 so I’m guessing that’s the cause of problem?
I’m sure its something simple but I’ve spent hours trying to solve this using templating on the developer tools page to no avail so any suggestions would be greatfully received.
Thanks
Tony
I agree that would be the most logical way to do it but can’t see how to setup separate topics on the Tasmota configuration page. When I enable the second sensor it automatically appends the data to that from the first and adds the GPIO pin number to the sensor name i.e AM2301-04 & AM2301-05.
Regards
Tony
Yes I did but I only included the sensor configuration for one of the sensors in my post as an example. I actually have four sensors configured in total Temp & Humidity for AM2301-04 (the two I posted) and Temp & Humidity for AM2301-05 - all four report “unknown”.
Thanks @myle but unfortunately neither options work, the double quotes give the following error in the log:
Invalid config for [sensor.mqtt]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data ['value_template']. Got '{{ value_json.["AM2301-04"].Temperature }}'. (See /home/homeassistant/.homeassistant/sensors.yaml, line 80). Please check the docs at ......
Using single quotes gives the following in the log and results in HA not starting.
2020-03-12 23:30:18 ERROR (SyncWorker_0) [homeassistant.util.yaml.loader] while parsing a block mapping
in "/home/homeassistant/.homeassistant/sensors.yaml", line 81, column 3
expected <block end>, but found '<scalar>'
in "/home/homeassistant/.homeassistant/sensors.yaml", line 86, column 36
2020-03-12 23:30:18 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping
in "/home/homeassistant/.homeassistant/sensors.yaml", line 81, column 3
expected <block end>, but found '<scalar>'
in "/home/homeassistant/.homeassistant/sensors.yaml", line 86, column 36
Thanks for your efforts @myle , I’m at work now but will try again when I get back home. The only difference I can see between what I tried earlier and what you’ve tried is that I’m pretty sure I had a . between value_json and the first [ so I tried
"{{ value_json.['AM2301-04'].Temperature }}"
rather than
"{{ value_json['AM2301-04'].Temperature }}"
as suggested by yourself. That may well be the difference, I’ll let you know how I get on.
Thanks @myle There must have been something screwed up in my syntax somewhere because even when I modded my sensor.yaml along the lines of yours it still didn’t work! In the end I copied and pasted your syntax from the post above into my yaml and that solved it.
Thanks again.
Tony