Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95414

Automation Syntax Help

$
0
0

@hoyt wrote:

Sorry for the generic title, not sure how else to summarize this.

I built a python script on a device on my network that sits behind a VPN. The python script calls my HA instance and updates an entity called vpn_ip. I put this in crontab and it runs every few minutes. When HA first starts, I set this value to unknown, and then on the next crontab run, it should update to the external IP address (I’m calling https://api.ipify.org?format=json in that script and it should respond back with the IP). If the vpn device cannot talk to the internet (ie - the VPN went down), the request will timeout, the VPN device then updates HA with a value of TIMEOUT. I have an automation (that works), which uses pushbullet to send a push if the status changes to TIMEOUT. I’m now trying to build a basic binary sensor that will show on/ or for the vpn status. I came up with this, but it’s not changing the status of the binary_sensor at all:

- id: '1573837112220'
  alias: VPN Up
  description: ''
  trigger:
  - entity_id: sensor.vpn_ip
    from: unknown
    platform: state
  condition: []
  action:
  - condition: state
    entity_id: binary_sensor.vpn_status
    state: >-
      '{%
      if 
        is_state('sensor.vpn_ip','unknown') or is_state('sensor.vpn_ip','TIMEOUT') or  is_state('sensor.vpn_ip','URL_ERROR')
      %}
        true
      {% else %}
        false
      {% endif %}'

I did the opposite on my existing automation (to: TIMEOUT), by adding a second action after the pushbullet call, but that isn’t working either. I’m not entirely sure what I have wrong, but I assume it’s in the state: element.

Thanks!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95414

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>