I am trying to cast the bitcoin price to my google home device group if it is above a certain value at a particular time in the day. The automation is not respecting the bitcoin price, and not stating the actual value of the bitcoin. What am I doing wrong? I am fairly new to hass
configuration.yaml
sensor:
- platform: bitcoin
display_options:
- exchangerate
automations.yaml
- alias: 'Bitcoin value exceeds 16000'
trigger:
- platform: time
at: '18:00:00'
- platform: numeric_state
entity_id: sensor.bitcoin
value_template: '{{states.sensor.bitcoin.state.attributes.exchangerate}}'
above: 16000
action:
service: tts.google_say
entity_id: media_player.all
data:
message: 'Bitcoin is trading at {{state.attributes.exchangerate}}'
language: 'en'
cache: false
Try changing
message: 'Bitcoin is trading at {{state.attributes.exchangerate}}'
to
message: 'Bitcoin is trading at {{state.sensor.bitcoin.attributes.exchangerate}}'
That did not work. It is still reading out “state dot sensor dot bitcoin dot attributes dot exchangerate”.
Two more changes should get you up and running
You’re creating a template, so you need to change
data:
to
data_template:
and
{{state.sensor.bitcoin.attributes.exchangerate}}
should be
{{states.sensor.bitcoin.attributes.exchangerate}}
A typo introduced by me
Apologies for the delayed response. I am not sure how I am creating a template (is it because I am specifying value_tempalate?), but this change did not work. In fact it did not even trigger the casting at all. Any other ideas?
Hmmm,
Can you post your code for the automation and the sensor please ?
I have removed identifying information using the tag.
automations.yaml (505 Bytes)
configuration.yaml (2.0 KB)
Your indenting was out and the sensor name incorrect.
The below code works for me ( changing the media player, at least when I force the trigger )
- alias: 'Bitcoin value exceeds 16000'
trigger:
- platform: time
at: '16:03:00'
- platform: numeric_state
entity_id: sensor.bitcoin
value_template: '{{states.sensor.exchange_rate_1_btc.state}}'
above: 19000
action:
- service: tts.google_say
entity_id: media_player.all
data_template:
message: 'Bitcoin is trading at {{states.sensor.exchange_rate_1_btc.state}}'
cache: false
1 Like