Hello,
I have my ac setup so I can change the temperature by “states(‘input_number.temperature’)”
However I would need to make an automation that updates this input number to a sensor that I can send to my HomeKit so I easily can see what temperature my ac set at on HomeKit.
Does anyone know any easy way to set this up?
Kind regards
Dujith
(Charles Evers)
June 5, 2022, 11:20am
2
Do you want to create a sensor based on that input_number?
If so then a template sensor would do the trick:
template:
- sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperature.state | round(1, default=18) }}
ps. i would avoid calling an input_number something as generic as temperature. Might become an issue later on when you have more.
1 Like
Yeah something like this, okay thanks and I would just add this to my configuration.yaml?
okay yeah right I should probably specify better name for the specific so I don’t mix up the names, thanks for the tip!
Dujith
(Charles Evers)
June 5, 2022, 11:53am
4
You can add this directly into your configuration.yaml or create a separate file and include it in the configuration.yaml
Best to get used to splitting the config when your just starting then having to do this later on.
So for example in configuration.yaml :
template: !include templates.yaml
And the template yaml: (templates.yaml )
sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperature.state | round(1, default=18) }}
Or if you dont want to split, put this in your configuration.yaml :
template:
- sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperature.state | round(1, default=18) }}
3 Likes
I get this error code when I try to check the yaml
Error loading /config/configuration.yaml: invalid key: "OrderedDict([('states.input_number.temperatureac.state | round(1', None), ('default=17)', None)])" in "/config/templates.yaml", line 4, column 0
I change the entity id to “input_number.temperatureac”
swell changed it default to 17 as that the lowest it can go, tho it dont make any matter if I put it on 18 I get same error.
Dujith
(Charles Evers)
June 5, 2022, 12:54pm
6
Can you post the configuration.yaml
and templates.yaml
1 Like
# 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
logger:
default: critical
logs:
# log level for HA core
homeassistant.core: fatal
- sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperatureac.state | round(1, default=17) }}
Dujith
(Charles Evers)
June 5, 2022, 1:05pm
8
sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperatureac.state | round(1, default=17) }}
Remove the - from sensor
1 Like
I removed - and used this instead
sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperatureac.state | round(1, default=17) }}
but still giving me error
Error loading /config/configuration.yaml: invalid key: "OrderedDict([('states.input_number.temperatureac.state | round(1', None), ('default=17)', None)])" in "/config/templates.yaml", line 4, column 0
Dujith
(Charles Evers)
June 5, 2022, 1:22pm
10
Remove the template: !include templates.yaml line from your config and insert this in the configuration.yaml
template:
- sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperatureac.state | round(1, default=18) }}
1 Like
# 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
logger:
default: critical
logs:
# log level for HA core
homeassistant.core: fatal
template:
- sensor:
- name: "AC Set Temperature"
unit_of_measurement: "°C"
state: {{ states.input_number.temperatureac.state | round(1, default=18) }}```
unfortunately I still get the same error, does it matter something with my temperature entity? Like it goes from 17-30, and its a number type.
Error loading /config/configuration.yaml: invalid key: "OrderedDict([('states.input_number.temperatureac.state | round(1', None), ('default=18)', None)])" in "/config/configuration.yaml", line 22, column 0
Dujith
(Charles Evers)
June 5, 2022, 1:39pm
12
O f me…
In this format you need to add the ’ after state if you dont use >
state: '{{ states.input_number.temperatureac.state | round(1, default=18) }}'
Also you copied ``` at the end there
2 Likes
ohh thanks mate! Works perfectly!
1 Like
Dujith
(Charles Evers)
June 5, 2022, 1:53pm
14
I feel so dumb right now. But glad i could help
1 Like
haha no without you I couldn’t have done it
Is there any way to speed up the refresh rate of it?
No worries about the last question, I found out that i can setup in my HomeKit app that after I press temp up it refreshes the sensor directly! Works fantastic. Massive thanks dude! It couldn’t have worked out better!!!