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

Weather value only if greater than zero

$
0
0

Hi, I created the template sensor

- trigger:
    - platform: time_pattern
      hours: /1
  action:
    - service: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.openweathermap
      response_variable: hourly
  sensor:
    - name: Home Weather Forecast Hourly
      unique_id: f257b8b3-1cee-4130-9dd6-158a1e8f13da
      state: "{{ now().isoformat() }}"
      attributes:
        forecast: "{{ hourly['weather.openweathermap'].forecast }}"

And an automation

service: telegram_bot.send_message
data:
  message: >-
    Outside temperature is {{
    states.weather.openweathermap.attributes.temperature }} °C.

    The raining chances are:  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[0].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[0].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[1].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[1].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[2].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[2].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[3].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[3].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[4].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[4].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[5].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[5].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[6].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[6].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[7].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[7].precipitation_probability }}%  {{- '\n' -}} At {{
    state_attr('sensor.home_weather_forecast_hourly', 'forecast')[8].datetime |
    as_timestamp | timestamp_custom('%H:%M') }} - {{
    state_attr('sensor.home_weather_forecast_hourly',
    'forecast')[8].precipitation_probability }}%

Where to input an if statement to receive only the lines if precipitation_probability is greater than zero and if all values are zero, to not receive at all?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106117

Trending Articles



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