a precision, configuration check is green, but sensor is shown unavailable/Unknown in the dashboards
Just because your configuration is free from (so to speak) grammatical errors the check for validity does not say your code will be working. (Like you could be waiting for a state āonā but the entity returns ātrueā instead - that would never be covered by the config-check. Itās just a syntax check, not more.
You arenāt showing enough of the working YAML, and you arenāt using code tags.
I have never used a cover device, and this is just a guess that isnāt likely to work. And I am assuming that itās a switch (the missing part of your YAML).
mqtt:
switch:
- name: "Garage Motion"
state_topic: "blueiris/garagehd"
qos: 1
payload_on: "on"
off_delay: 30
Itās likely a binary_sensor being a motion sensor.
mqtt:
binary_sensor:
- name: "Garage Motion"
state_topic: "blueiris/garagehd"
qos: 1
payload_on: "on"
off_delay: 30
I already had everything split out and really didnāt want to combine it again, so I did thisā¦
configuration.yaml
---
mqtt:
binary_sensor: !include_dir_merge_list mqtt/binary_sensor/
button: !include_dir_merge_list mqtt/button/
cover: !include_dir_merge_list mqtt/cover/
fan: !include_dir_merge_list mqtt/fan/
light: !include_dir_merge_list mqtt/light/
lock: !include_dir_merge_list mqtt/lock/
sensor: !include_dir_merge_list mqtt/sensor/
switch: !include_dir_merge_list mqtt/switch/
Then tweaked the top of the files to remove platform, dropped the files into their folders where they fit from the prior integrations, and done.
I probably will adjust things with friendly names now that I can and make it all look the same, clean it up, but itās working again and no broken entities or required name changes.
File Structureā¦
Do any of you know what is working equivalent of:
light: !include_dir_merge_list cfg/lights/
with contents:
- platform: mqtt
name: "Kinkiet Hall"
command_topic: milight/0x8164/rgb_cct/3
state_topic: milight/states/0x8164/rgb_cct/3
schema: json
color_temp: true
rgb: true
brightness: true
with RGB colors, color brightness and white color temp?
I really canāt make it working under new format
Look at the post directly above yours. You have to move that file to a new driectory and remove - platform mqtt, but keep the -, so put it on the next line.
yes, check MQTT Light - Home Assistant which clearly states the hierarchy.
# Example configuration.yaml entry
mqtt:
light:
- command_topic: "office/rgb1/light/switch"
first 2 lines of these are already in your configuration.yaml with the include, so do as Petro states and start with the 3d line
No, I did it with all switches, sensors and so on and it works.
With lights itās deferent, as now it refuses to accept combination of color_temp, rgb, brightness.
thats probably because you dont use the correct keys (configuration variables). check the section below what I posted, and see thereās a _topic
behind most of these
edit
see MQTT Light - Home Assistant for the docs on what Petro says belowā¦
change
to
supported_color_modes:
- rgb
Thanks for sharing this, I learned something: I didnāt know about !include_dir_merge_list
.
I ended up using a separate file for each list of binary_sensor, sensor, etc. Then I created a single mqtt.yaml file that includes those files. I include that mqtt.yaml in configuration.yaml. So: more layers, maybe too much ā will see the next time I have to add more MQTT devices. My mqtt.yaml looks thisā¦
binary_sensor: !include mqtt_binary_sensor.yaml
sensor: !include mqtt_sensor.yaml
device_tracker: !include mqtt_device_tracker.yaml
Youāre literally describing packages. A package is a way of grouping a bunch of different things that come together to make something else (a āunitā as you call it). Just use those.
Does anyone know if the format has also changed for MQTT triggers? Iāve tried looking all over the place and the documentation shows the method I am still using. Iām currently using this in my templates.yaml for some Plex automations:
- trigger:
- platform: mqtt
topic: "plex/update"
sensor:
- name: "Webhook Plex State"
state: >
{% if (trigger.payload_json.event == 'media.play') %}
playing
{% elif (trigger.payload_json.event == 'media.pause') %}
paused
{% elif (trigger.payload_json.event == 'media.resume') %}
resumed
{% elif (trigger.payload_json.event == 'media.stop') %}
stopped
{% elif (trigger.payload_json.event == 'media.rate') %}
rated
{% elif (trigger.payload_json.event == 'media.scrobble') %}
90% viewed
{% endif %}
- name: "Webhook Plex Player"
state: "{{ trigger.payload_json.Player.title }}"
- name: "Webhook Plex Media Type"
state: "{{ trigger.payload_json.Metadata.type }}"
- name: "Webhook Plex Media Title"
state: "{{ trigger.payload_json.Metadata.title }}"
- name: "Webhook Plex Media Length"
state: "{{ ((trigger.payload_json.Metadata.duration|float)/60000) }}"
In the documentation those first 3 lines are the same format. I was wondering if this would also change to:
- mqtt:
- trigger:
topic: "plex/update"
or something similar.
Thatās the template integration, not mqtt. So no changes.
Thanks for the information. This has been bugging me for quite some time and was getting nowhere finding the answer.
Iām a simple user that have a very small knowledge about yaml files, coding etc. - Iām expanding my HA setup following the āmore configuration from the UIā trend.
I got this error from the check configuration addon, but only when trying to install 2022.07 - no errors before:
WARNING:homeassistant.components.mqtt.mixins:Manually configured MQTT sensor(s) found under platform key 'sensor', please move to the mqtt integration key, see https://www.home-assistant.io/integrations/sensor.mqtt/#new_format
I havenāt any āplatform: mqttā in my configuration.yaml and I donāt know if I also have to look elsewhere.
Should I have to look in hacs custom component? In packages dir? I have only a few packages (smart irrigation and zigbee2mqtt), should I check and if needed, modify them?
No
I was going to say yes but then you called zigbee2mqtt a package. Do you actually mean packages or do you really mean addons? If you mean addons then no, those have nothing to do with this. If you actually mean packages then yes you should look at the config of those packages.
What youāre looking for is this:
- Somewhere in your
configuration.yaml
file it should havesensor:
- Under that should be something with
platform: mqtt
.- Note this may be in a different file if you have something like
sensor: !include sensors.yaml
in yourconfiguration.yaml
. Then look in that file instead
- Note this may be in a different file if you have something like
- This is the deprecated format. Follow the documentation and the guidance in this thread to move those entries out from being under
sensor:
and to being undermqtt:
in yourconfiguration.yaml
If you actually did mean packages above then similar logic applies there. Look in each of your packages and find platform: mqtt
under sensor:
and refactor in the same way. Or ask the package author for an update if you copied it from the forum or something.
Thank you for your reply.
I just waited, and with 2022.07.3, the error is gone so I am not sure if actually there were a platform:mqtt somewhere.
Are there any limitations to using MQTT sensors in packages? As I rewrote my custom integrations to the new MQTT format I had to split the different types of entities into multiple files, a bit annoying as previously had everything related to a specific integration in one file. But everything worked again and no warnings so, happy times! Then I learned about packages and thought that sounds like a great way to arrange those entities back into one file again. However, I canāt get the package to workā¦ I get no configuration errors so I guess formatting is ok, but the entities show up as āunavailableā when I move them into a package.
This is my current configuration.yaml simplified:
homeassistant:
packages:
my_package: !include packages/my_package.yaml
And this is the structure of my_package_yaml
mqtt:
sensor:
- name: "a name"
template:
sensor:
- name: "another name"
sensor:
- platform: history_stats
name: "A historical name"
Any obvious mistakes here that explains the behavior of the entities not showing up?