Trigger wind-alarm state every minute

Hi,

I have a KNX-group 4/0/9 “Wind-Alarm” with an MDT Jal-0810 actor.
Since I don’t have any KNX wind sensor device yet, that measures the true wind, I just requested the wind-data from the local weather data provider, which is currently good enough.

So the entity “sensor.local_wind_speed” delivers the current wind-speed in km/h
I want to forward an alarm-value with binary-value “true” to the KNX wind alarm group, if the wind exceeds 60 km/h.
The actor is waiting for a signal at least every 3 minutes or less. Otherwise wind-alarm is automatically set to true.
Therefore I want also to forward a signal “false” every 1 minute to the alarm-group, to inform the group, that the measurement-device still works but values are ok.

I don’t figure out how to set something like this up in home assistant.
Tried a lot around and did some search, but I don’t really figure out how to work with the templates, conditionals and triggers yet.

Here is one of my trials (of course there are a lot of errors, but I’m missing any clue):

alias: "Windalarm"
''trigger:
''''platform: time_pattern
''''''minutes: "/1"
''action:
''''service: knx.send
''''''address: '4/0/9'
''''''type: 'binary'
''''''condition: template
''''''value_template: '{{states('sensor.local_wind_speed') > 60}}'

Knx.send doesn’t take a type argument, but just raw values - it is more or less a debug service.
Expose a sensor of type binary and use this.

Why all these single quotes in the beginning of every line of code? Your indentation is also wrong, did you take a look at the automation documentation and some examples?

Hello farmio,

thanks a lot - I’m getting already a bit closer:

created a binary sensor to create the entity and later sync the state of the wind-alert from a KNX-device (that may come in future)


binary_sensor:

''- platform: knx
''''name: windalarm
''''state_address: '0/0/5'
''''sync_state: true

created the exposure of the binary_sensor-entity to inform the KNX-group

knx:
''''expose:
''''''- type: 'binary'
''''''''entity_id: 'binary_sensor.windalarm'
''''''''address: '0/0/5'

Now what I’m still missing is the correct automation for the trigger, to change the value of the binary_sensor-entity to 1, if the wind-speed increases 60 km/h

here is a try to verify every 1 minute the current state and set the binary-sensor.
I just want to change the sensor-state to the value of a true/false state if the weather-data gives a value greater or lower than 60 km/h

automation:
  trigger:
    platform: time_pattern
    minutes: "/1"
  action:
    service: switch.toggle
    value_template: "{{ is_state('trigger.to_state.sensor.weather-data_wind_speed'>60) }}"
    entity_id: binary_sensor.windalarm

Im not entirely sure. Try to use a template sensor combined with the expose sensor instead of a binary_sensor.
The binary_sensor device is for Knx to HA - not the other way around.

hm,
the binary function already works:
If I set the binary sensor state manually to true, the KNX-Jal-actor notices the windalarm.
What I didn’t figure out yet is how to trigger the signal of the local weather-supplier into a boolean sensor value once a minute.

So if the local weather supplier reports, that the wind speed exceeds 60 km/h, I want to change the value of “binary_sensor.windalarm” to true. Otherwise the value is false.
I think about an automation rule with a trigger command. But I don’t know how to handle these variables yet.

If you create an expose sensor with an entity_id of a binary sensor with the same GA double check that you didn’t create a loop on your bus. Therefore I suggested the template sensor.

I’d just create an automation that triggers to on when wind is > 60 and off when it’s < 40 or so. The periodical sending could be an extra (third) automation.

Create a template binary sensor that shows true if wind > 60 kmh something like this:

binary_sensor:
  - platform: template
    sensors:
      wind_above_60:
        friendly_name: "Wind above 60"
        value_template: >-
          {{ states('sensor.local_wind_speed') | int > 60 }}

This binary sensor shows “on” when wind speed is above 60 and “off” otherwise.

Thats it and exactly what I was looking for!
Works great - thanks!

I thought the template-platform comes always with a trigger or conditional automation, but didn’t know that one can use it also as a sensor.
Do I need any conditional- or trigger-commands as well for this?

Take a look here for more details Template Binary Sensor

What do you mean with this? The binary sensor evaluates the value_template everytime the “sensor.local_wind_speed” changes.

I mean, what is then actually the reason for using conditionals?
Even or/and-commands could be easily done using sensors like above and stay more simple?

When is it necessary to use conditional types?

I don’t understand what conditionals you are talking about.
Are you talking about automations? You may be confused because you wanted to set the binary sensor with an automation and I showed you a way that the binary sensor sets the state himself without using an automation.

Yes, thats may be the reason.
You showed me the way it works without automation and the problem is solved right now.

I will find out when the automation makes more sense, once I have a real reason to use it.

Thank you again.