Hello,
I have added my Sonoff-TH16 switch/sensor in to my home assistant, but I can’t display my temperature on my lovelace. I think it is because de entity is an switch and not an sensor. So does anyone know how I can fix this problem?
Hello,
I have added my Sonoff-TH16 switch/sensor in to my home assistant, but I can’t display my temperature on my lovelace. I think it is because de entity is an switch and not an sensor. So does anyone know how I can fix this problem?
Here’s one way to do it:
Create a Template Sensor that acquires its state value from the Sonoff switch’s temperature
attribute.
# Example configuration.yaml entry
sensor:
- platform: template
sensors:
aquarium_temperature:
friendly_name: 'Aquarium Temperature'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.sonoff_bea5b1', 'temperature') }}"
Now you’re able to display sensor.aquarium_temperature
in the UI.
Another way is to use a card that is able to display an entity’s attributes, like this one:
It’s working thankyou!!
worked perfectly, but how can I add Humidity sensor?
iam using sonoff TH16.
# Example configuration.yaml entry
sensor:
- platform: template
sensors:
aquarium_temperature:
friendly_name: 'Aquarium Temperature'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.sonoff_bea5b1', 'temperature') }}"
aquarium_humidity:
friendly_name: 'Aquarium Humidity'
unit_of_measurement: '%'
value_template: "{{ state_attr('switch.sonoff_bea5b1', 'humidity') }}"
Thanks a lot.
How can combine all in one as into the climate.
Now i have only the temp. but i want to have the Humidity as well.
I don’t understand your question. Where do you see humidity displayed in the climate component?
Hi!
Im using HA for 1 day now, so im totally green, this post helped me at begining.
I have about 50 sonoff’s POW R2 still on original firmware, using AlexxIT component.
What im trying to achieve is reading voltage, current, power and power usage daily, monthly, previous month total usage of each one and would be great if those restart each month first day.
Any tips how to do that would be very apreciated.
Right now i did smthing like that:
sensor:
I can’t get this to work for me. Code below. I’ve checked the device MQTT console and the data is being output. In the HAS logs/GUI there’s no data?
# TH16 2 Study Climate
- platform: template
sensors:
temperature_study:
friendly_name: 'Temperature Study'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.lahar_54F1B4', 'temperature') }}"
humidity_study:
friendly_name: 'Humidity Study'
unit_of_measurement: '%'
value_template: "{{ state_attr('switch.lahar_54F1B4', 'humidity') }}"
dewpoint_study:
friendly_name: 'Dew Point Study'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.lahar_54F1B4', 'dewpoint') }}"
Can you show the mqtt messages received?
how do I round this to 2 digits
value_template: “{% set p=state_attr(‘switch.sonoff_100054cd9a’, ‘consumption’) %}{{ p[:14]|sum if p }}”
this dont work
value_template: “{% set p=state_attr(‘switch.sonoff_100054cd9a’, ‘consumption’) %}{{ p[:14]|sum if p | round (2) }}”
I just flashed and configured tasmota on my new TH16 but my attributes only show ‘friendly name’. Can someone guide me what i’m missing in my mqtt config please?
- platform: mqtt
name: "aqua light"
state_topic: "stat/sonoff_th1/POWER"
command_topic: "cmnd/sonoff_th1/POWER"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
All sorted. Thanks everyone
Hi there!
I’m trying to get the temperature from a sonoff device. I have inserted this section on my /config/configuration.yaml file:
sensor:
- platform: template
sensors:
outside_temperature:
friendly_name: 'Outside Temperature'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.sonoff_10006d131c', 'temperature') }}"
No errors found on the file syntax however, I cannot find the sensor in order to add it to my lovelace.
Am I forgetting anything?
Thanks in advance for your support.
Do you have more than one sensor:
section in configuration.yaml
?
No. Here’s the full code:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sonoff:
username: xxxxxxxxxxx
password: xxxxxxxxxxx
sensor:
- platform: template
sensors:
outside_temperature:
friendly_name: 'Outside Temperature'
unit_of_measurement: '°C'
value_template: "{{ state_attr('switch.sonoff_10006d131c', 'temperature') }}"
EDIT
I guess I found the issue… One extra space before the word ‘sensor’
Two extra spaces; remove them.
value_template: “{% set p=state_attr(‘switch.sonoff_100054cd9a’, ‘consumption’) %}{{ p[:14]|sum|round(2) if p }}”
OR
value_template: “{% set p=state_attr(‘switch.sonoff_100054cd9a’, ‘consumption’) %}{{ (p[:14]|sum if p) | round(2) }}”
I created the temperature sensor from TH16 using your indication Taras.
Now I would like to use automation to switch on or switch off the switch if temperature is high (for example) 19° Switch on and switch off then high than 20.
I wrote these automation but seams doesn't work. Could you help me ?
Thanks
Stefano
- id: '1607209649167'
alias: 'TERMOSTATO: ON temp<25'
description: Accende se temp < 25
trigger:
- platform: numeric_state
entity_id: sensor.termostato1
below: '25'
condition: []
action:
- service: switch.turn_on
data: {}
entity_id: switch.sonoff_1000f1eab4
mode: single
- id: '1607209710596'
alias: 'TERMOSTATO: OFF temp>25'
description: Spegne se temp > 25
trigger:
- platform: numeric_state
entity_id: sensor.termostato1
above: '25'
condition: []
action:
- service: switch.turn_off
data: {}
entity_id: switch.sonoff_1000f1eab4
mode: single
Many Sonoff switch can output their wifi signal strength as well as follows:
- platform: template
sensors:
rssi_sonoff_name:
friendly_name: "WiFi Signal Strength Name"
unit_of_measurement: db
value_template: "{{ state_attr('switch.sonoff_name', 'rssi') }}"