Advertisement
bdnstn

Logic problem

Jun 12th, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.69 KB | None | 0 0
  1. globals:
  2.   - id: is_summer      
  3.     type: bool
  4.     initial_value: "false"
  5.     restore_value: true
  6.   - id: is_winter_water_day      
  7.     type: bool
  8.     initial_value: "false"
  9.     restore_value: true
  10.   - id: weather_factor
  11.     type: float
  12.     initial_value: "1"
  13.     restore_value: true
  14.   - id: sun_low_pm
  15.     type: bool
  16.     restore_value: true
  17.     initial_value: "false"
  18.   - id: odd_day
  19.     type: bool
  20.     restore_value: true
  21.   - id: month_no
  22.     type: int
  23.     initial_value: "99"
  24.     restore_value: true
  25.   - id: week_day_no
  26.     type: int
  27.     initial_value: "99"
  28.     restore_value: true
  29.  
  30. time:
  31.   - platform: sntp              # Changed from homeassistant to sntp on 1/5/24
  32.     timezone: Australia/Perth
  33.     id: ha_time
  34.     on_time:
  35.       - seconds: 0
  36.         minutes: 0
  37.         hours: 0
  38.         then:
  39.          # Watering restrictions for bores in Busselton.
  40.           # Every day from 1 Sept to 31 May, once per day, before 9am or after 6pm. Summer = months 9, 10, 11, 12, 1, 2, 3, 4, 5.
  41.           # Pressure testing, once a week, for 2 minutes per station. Pref before 9am or after 6pm. Winter = months 6, 7, 8.
  42.           - lambda: |-
  43.               auto time = id(ha_time).now();
  44.               id(month_no) = time.month;
  45.               id(week_day_no) = time.day_of_week;
  46.               id(is_summer) = (time.month > 8 or time.month < 6);
  47.               id(is_winter_water_day) = ((not id(is_summer)) and (time.day_of_week == 5));
  48.               id(odd_day) = (time.day_of_year % 2 != 0);
  49.  
  50.           - pulse_meter.set_total_pulses:
  51.               id: retic_flow
  52.               value: 0
  53.           - pulse_meter.set_total_pulses:
  54.               id: bore_flow
  55.               value: 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement