Hello everyone, I have been running the Fhem server for my smart home project for the past few years. Now I installed Home Assistant a few days ago, as I would like to switch in the long term.
I am currently still having difficulties with one or two issues and need your help. Unfortunately, Chat-GPT couldn’t really help me.
I have a Tasmota sensor which sends me values from my electricity meter via MQTT to my broker at IP 192.168.178.99. This also works more or less.
However, I cannot read the sensor within Home Assistant. As soon as I try to select the entity, I get the error that this is not available.
The MQTT explorer shows me all the required values. The values are also displayed in Fhem without any problems.
Meine configuration.yaml
Blockquote
mqtt:
sensor:
- name: “Stromzaehler SML2 Power”
state_topic: “Strom/tele/SENSOR” # Hier sicherstellen, dass das richtige Topic verwendet wird
value_template: “{{ value_json.SML2.Power_curr }}” # Der Wert von Power_curr aus der JSON-Nachricht
unit_of_measurement: “W”
device_class: power
unique_id: “0DEC7B_SML2_Power_curr”
Please re-post your code formatted correctly. Use the </> button. Should look like this:
mqtt:
sensor:
- name: (uzw)
You have pasted it as a blockquote, which destroys indentation and exchanges “real” quotes for “smart” ones. There might be errors in your code that are not apparent to us.
If this is your first MQTT sensor in the configuration file, you must restart HA to load it up.
If that doesn’t help, please paste a screenshot from MQTT Explorer showing the topic and the data.
Where are you trying to “select the entity”, and what does the error look like?
Have you set up your MQTT broker in HA? Do you have a screen like this under Integrations?
Thanks for your help. Unfortunately everything is in german. I hope you can unterstand it anyway
Every time I change something in the configuration.yaml, I reload it and also restart Home Assistant.
mqtt:
sensor:
- name: "Stromzaehler SML2 Power"
state_topic: "Strom/tele/SENSOR" # Hier sicherstellen, dass das richtige Topic verwendet wird
value_template: "{{ value_json.SML2.Power_curr }}" # Der Wert von Power_curr aus der JSON-Nachricht
unit_of_measurement: "W"
device_class: power
unique_id: "0DEC7B_SML2_Power_curr"
with the other lines deliberately removed. The state of that sensor should now be the first 250 characters of the topic response, just to check that any data is getting through.
Now you should be able to reply with the MQTT Explorer screenshot
The screenshot the OP posted is a device that was automatically discovered (via MQTT) by the Tasmota integration. The device is a switch with several sensors (all appear to be unavailable).
The OP appears to be trying to rectify the situation by manually defining an MQTT Sensor … which is also reporting it’s unavailable.
There appears to be an underlying problem that affects both automatically and manually created entities for the device.
omeassistant:
name: Home
latitude: XXX # Breite, z.B. für Berlin
longitude: XXX # Länge, z.B. für Berlin
elevation: 34 # Höhe über dem Meeresspiegel
unit_system: metric # metrisches System (Celsius, km/h)
country: DE # Land, z.B. Deutschland
currency: EUR # Währung
country_code: de # Ländercode
time_zone: "Europe/Berlin" # Zeitzone
media_dirs:
media: "/mnt/your_media_folder" # Pfad für Medieninhalte
# Automatisierungen und Szenen
automation: !include automations.yaml
scene: !include scenes.yaml
# Beispiel für eine einfache Wetterintegration
weather:
- platform: openweathermap
api_key: "YOUR_OPENWEATHERMAP_API_KEY"
# Beispiel für eine MQTT-Integration (Smart Home Geräte)
mqtt:
sensor:
- name: "Stromzaehler SML2 Power"
state_topic: "Strom/tele/SENSOR" # Hier sicherstellen, dass das richtige Topic verwendet wird
value_template: "{{ value_json.SML2.Power_curr }}" # Der Wert von Power_curr aus der JSON-Nachricht
unit_of_measurement: "W"
device_class: power
unique_id: "0DEC7B_SML2_Power_curr"
# Beispiel für eine Lichtsteuerung mit MQTT
light:
- platform: mqtt
name: "Wohnzimmer Lampe"
state_topic: "home/lights/livingroom/state"
command_topic: "home/lights/livingroom/set"
brightness_state_topic: "home/lights/livingroom/brightness/state"
brightness_command_topic: "home/lights/livingroom/brightness/set"
payload_on: "ON"
payload_off: "OFF"
# Beispiel für einen MQTT-Sensor (Temperatur)
sensor:
- platform: mqtt
name: "Temperatur Sensor"
state_topic: "home/sensors/temperature"
unit_of_measurement: "°C"
switch:
- platform: mqtt
name: "NOUS A1T Steckdose"
state_topic: "stat/nous_a1t_steckdose/tasmota_181194"
command_topic: "cmnd/nous_a1t_steckdose/tasmota_181194"
payload_on: "ON"
payload_off: "OFF"
qos: 1
# Beispiel für eine Benutzerdefinierte Automation
automation:
- alias: "Licht einschalten bei Bewegung"
trigger:
platform: state
entity_id: binary_sensor.motion_sensor
to: "on"
action:
service: light.turn_on
target:
entity_id: light.wohnzimmer_lampe
# Zigbee2MQTT Integration
zigbee2mqtt:
mqtt:
base_topic: zigbee2mqtt
server: "mqtt://localhost"
user: "mqtt_user"
password: "mqtt_password"
permit_join: false
device_options:
- option1: value1
- option2: value2
# Beispiel für die Integration von Alexa
alexa:
smart_home:
endpoint: "https://api.amazonalexa.com/v3"
client_id: "your_alexa_client_id"
client_secret: "your_alexa_client_secret"