MQTT based sprinkler control

Thank you. Are you creating your own project of following someone else’s? Was maintenance the only factor for moving away from this code? Was there reliability issues or anything?

I keep having issues with binary sensor erroring, could you help?


Should be “sensors” not “sensor”. Like this:

binary_sensor:
    - platform: template
      sensors:
        zone_1_day_active:
1 Like

Thanks! Ill test tomorrow and report back

Still having issues, Not sure why.

Move everything on lines 7 through 24 to the right by 4 spaces.

Note

This Template Binary Sensor will be affected by an upcoming change to the Template integration:

In a nutshell, the entity_id option is deprecated so you will have to incorporate sensor.date within the template.

1 Like

Awesome! Thank you, That worked!

What component or method are you using to get rainfall data?

it says in this post.

Thanks, looks like that weather service is specific to your area. Seems ones I use don’t have any rainfall data. I will have to see how the moisture sensors work. IDK how I’d do it because they are BLE. Might have issues with distance.

Try this. Then you can use weather.home https://www.home-assistant.io/integrations/met

I live in USA and use this.

Does this do rain accumulation based on local data? I’m just curious of how the data is interpreted.

Thanks!

I know you can make a sensor to reset every so often, I dont think it stores anything, just shows future.

For future reference, when the breaking change (deprecation of entity_id) is implemented in the Template integration, here is a version of your Template Binary Sensor that should be compatible.

First, you will need to define a group containing the input_booleans representing the weekdays:

group:
  zone_1_weekdays:
    name: Zone 1 Weekdays
    entities:
      - input_boolean.zone_1_mon
      - input_boolean.zone_1_tue
      - input_boolean.zone_1_wed
      - input_boolean.zone_1_thu
      - input_boolean.zone_1_fri
      - input_boolean.zone_1_sat
      - input_boolean.zone_1_sun

The following template expands that group and also employs sensor.date.

  binary_sensor:
    - platform: template
      sensors:
        zone_1_day_active:
          friendly_name: Irrigation Day Active
          value_template: >-
            {% set today = states.sensor.date.last_updated.timestamp()
                 | timestamp_custom('%a') | lower %}
            {% set weekdays = expand('group.zone_1_weekdays')
                 | selectattr('state', 'eq', 'on')
                 | map(attribute='object_id')
                 | map('replace', 'zone_1_', '')
                 | list %}
            {{ today in weekdays }}

How it works:

  • It gets the current weekday’s abbreviation (mon, tue, wed, etc) from sensor.date and assigns it to a variable called today.
  • It expands the group, selects only the input_booleans that are on, gets their object_id (i.e. “zone_1_thu”), discards the “zone_1_” portion thereby only leaving the weekday abbreviation, and finally generates a list (like ['tue', 'thu']) and assigns it to the variable weekdays.
  • The final line simply checks if the value of today is in weekdays list and, if it is, returns true (otherwise, false).
1 Like

I’m actually thinking of moving all my schedules over to the custom scheduler card which should simplify things a bit.

How would I convert this to inches? i know there is rain tomorrow.

 sensor:
 - platform: template
   sensors:
    predict_rain_today:
      friendly_name: 'Predicted Rain Today'
      entity_id:
        - sensor.dark_sky_precip_probability_1d # always a single int
        - sensor.dark_sky_daily_max_precip_intensity_1d # two formats. Single int or "int_1 to int_2" e.g. "3 to 4"
      unit_of_measurement: in
      value_template: >
        {% set chance = states('sensor.dark_sky_precip_probability_1d')|int /100 %}
        {% if 'to' in states('sensor.dark_sky_daily_max_precip_intensity_1d') %}
          {% set amount =  states('sensor.dark_sky_daily_max_precip_intensity_1d').split(' to ')  %}
          {% set amount1 = amount[0] | float %}
          {% set amount2 = amount[1] | float %}
          {% set amount_avg = (amount1 + amount2) / 2 %}
        {% else %}
          {% set amount_avg = states('sensor.dark_sky_daily_max_precip_intensity_1d') | int %}
        {% endif %}
        {{ (chance * amount_avg)|round(1) }}

Please format your pasted config.

Basically, if it’s in mm, divide by 25.4 in the final amount template.

1 Like

Awesome thread.

I would be nice if anyone could share rough estimates/suggestions for the values of min_moisture, max_moisture, and min_conductivity for a typical lawn.

Thanks in advance and kind regards!

Is this config still working. I keep getting an error in log - entity_id is deprecated (I think in template, it is).
I got everything to work except the automation.

Hey guys

Really awesome thread, I’ve spent quite a bit of time getting this setup and it seems with the end in sight I’ve stopped short of the finish line :flushed:

I suspect it has something to do with the entity_id but don’t know how to fix it.

I’m getting the error “Entity not available: sensor.zone_1_time_remaining” and I’ve tried a few things but just cannot get that to come up for some reason. The automations are also not being activated and I’m not sure if its because of this sensor?

A nudge in the right direction would be greatly appreciated, my config files and screenshot below, thanks in advance.

binarysensors.yaml

- platform: template
  sensors:
    zone_1_day_active:
      friendly_name: Irrigation Day Active
      value_template: >-
        {% set today = states.sensor.date.last_updated.timestamp()
             | timestamp_custom('%a') | lower %}
        {% set weekdays = expand('group.zone_1_weekdays')
             | selectattr('state', 'eq', 'on')
             | map(attribute='object_id')
             | map('replace', 'zone_1_', '')
             | list %}
        {{ today in weekdays }}

- platform: template
  sensors:
    zone_1_time_remaining:
      friendly_name: 'Time Remaining'
      entity_id:
        - input_number.zone_1_time_remaining
        - sensor.time
        - switch.irrigation_z1
      value_template: "{{ [ (states('input_number.zone_1_run_time') | int - (as_timestamp(now()) - as_timestamp(states.switch.irrigation_z1.last_changed)) / 60) | round(0) ,0 ] | max }}"
##      unit_of_measurement: "min"

groups.yaml

  zone_1_weekdays:
    name: Zone 1 Weekdays
    entities:
      - input_boolean.zone_1_mon
      - input_boolean.zone_1_tue
      - input_boolean.zone_1_wed
      - input_boolean.zone_1_thu
      - input_boolean.zone_1_fri
      - input_boolean.zone_1_sat
      - input_boolean.zone_1_sun

automation.yaml

- id: '1608027082816'
  alias: Irrigation Zone 1 AM
  description: ''
  trigger:
  - platform: template
    value_template: '"{{ states(''sensor.time'') == states(''input_datetime.zone_1_am_on_time'').rsplit('':'',1)[0]
      }}"'
  condition:
  - condition: state
    entity_id: binary_sensor.zone_1_day_active
    state: 'on'
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.irrigation_z1
  - service: notify.mobile_app_paul_s9
    data:
      title: '*Information*'
      message: Zone 1 sprinklers turned on (AM Schedule).
  mode: single
- id: '1608028549476'
  alias: Irrigation Zone 1 PM
  description: ''
  trigger:
  - platform: template
    value_template: '"{{ states(''sensor.time'') == states(''input_datetime.zone_1_pm_on_time'').rsplit('':'',1)[0]
      }}"'
  condition:
  - condition: state
    entity_id: binary_sensor.zone_1_day_active
    state: 'on'
  action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.irrigation_z1
  - service: notify.mobile_app_paul_s9
    data:
      title: '*Information*'
      message: Zone 1 sprinklers turned on (PM Schedule).
  mode: single