Hi Guys
Thought this might help someone wanting to control the generic_thermostat component with a schedule
We converted to all electric storage heaters and 6.29kWh worth of solar panels with 10kWh battery storage but the heating controls were very basic i.e either on or off based on a preset time and preset high/low temperature over a 7 day period which was not very freindly to the pocket or usable
So, I have spent a fair bit of time getting my all electric heating into a very usable, configrabe state over the winter months by changing the heater controlls to Sonoff TH16’s (x 13 and tamotarised). I now have a good WAF rating on the heating setup as she can either control it via voice or the iOS app
So, Here goes. This is my setup (as of writing) which is running on a raspberrypi 3B+
Worth noting I split all my components into seperate config files using the “!include” option after each component making it easier to mange/update one component and not have a long configuration.yaml file
EDIT: Updated to Appdaemon V4 Add-on due to the following errors in Appdaemon
[hassio.api.proxy] Client error on WebSocket API Cannot connect to host 172.30.32.1:8123 ssl:False [Connection refused].
Which in turn was causing the following errors in the appdaemon log and hass was disconnecting and retry which was cuseing schedy to throw a wobbly
WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds
Homeassistant setup:
- Home Assistant release 0.105.1
- MQTT Server & Web client (Community Hass.io Add-ons)
- Appdaemon 3 v5.0.1 (Community Hass.io Add-ons) - replaced with Appdaemon 4 v0.1.2
Heater control devices:
- Sonoff’s are contolled/updated via MQTT and create the required temperature/humidity sensors and switch in Homeassistant per room
The following is added into my configuration.yaml file:
climate: !include climate.yaml
input_select: !include input_select.yaml
Then, Create a climate.yaml file in my /config folder with the following:
- platform: generic_thermostat
name: Entrance Heater
heater: switch.entranceheater
target_sensor: sensor.entranceheater_am2301_temperature
min_temp: 15.0
max_temp: 23.0
ac_mode: False
target_temp: 17.0
cold_tolerance: 0.0
hot_tolerance: 0.0
initial_hvac_mode: "off"
away_temp: 16
- platform: generic_thermostat
name: Bedroom Heater
heater: switch.bedroomheater
target_sensor: sensor.bedroomheater_am2301_temperature
min_temp: 15.0
max_temp: 23.0
ac_mode: False
target_temp: 17.0
cold_tolerance: 0.0
hot_tolerance: 0.0
initial_hvac_mode: "off"
away_temp: 16
Just duplicate as need for more heaters
Then, Create a input_select.yaml file in my /config folder with the following:
heating_mode:
name: Heating Status
options:
- Home
- Away
EDIT: Updated appdaemon to v4 from v3 - config added/updated
Appdaemon Setup:
Install and setup Appdaemon as per add-on instructions. Here is my Appdaemon Config for the add-on:
Appdaemon 3 Add-on config
disable_auto_token: false
system_packages: []
python_packages:
- hass-apps
init_commands: []
Appdaemon 4 Add-on config
system_packages: []
python_packages:
- hass-apps
init_commands: []
EDIT: added appdaemon.yaml
Here is my appdaemon.yaml file
Appdaemon 3
log:
logfile: STDOUT
errorfile: STDERR
appdaemon:
threads: 10
app_dir: /config/appdaemon/apps
plugins:
HASS:
type: hass
ha_url: http://hassio/homeassistant
token: GENERATE_LONG_LIVED_TOKEN_FOR_HASSAPPS_IN_HOMEASSISTANT
Appdaemon 4
secrets: /config/secrets.yaml
appdaemon:
latitude: xx.xxxxxx
longitude: -x.xxxxxx
elevation: 2
time_zone: Europe/London
plugins:
HASS:
type: hass
http:
url: http://127.0.0.1:5050
hadashboard:
admin:
api:
Hass-Apps Schedy Setup:
install and setup the basic hass-apps Schedy addin (https://hass-apps.readthedocs.io/en/stable/apps/schedy)
In the appdaemon folder update the hass-apps file created during setup or create a new one. Mine is called schedy_heating.yaml located in the “/config/appdaemon/apps” folder
schedy_heating: # This is our app instance name.
module: hass_apps_loader
class: SchedyApp
actor_type: thermostat
expression_environment: |
def heating_mode():
return state("input_select.heating_mode")
watched_entities:
- input_select.heating_mode
schedule_append:
- v: 17
rooms:
entrance:
rescheduling_delay: 120
actors:
climate.entrance_heater:
schedule:
- v: 17
rules:
- weekdays: 6-7
rules:
- rules:
- x: "Next() if heating_mode() == 'Home' else Break()"
- { v: 20.5, start: "09:00", end: "20:00" }
- rules:
- x: "Next() if heating_mode() == 'Away' else Break()"
- { v: 16 }
- rules:
- x: "Next() if heating_mode() != 'Home' else Break()"
bedroom:
rescheduling_delay: 120
actors:
climate.bedroom_heater:
schedule:
- v: 17
rules:
- weekdays: 6-7
rules:
- rules:
- x: "Next() if heating_mode() == 'Home' else Break()"
- { v: 20.5, start: "19:00", end: "22:00" }
- rules:
- x: "Next() if heating_mode() == 'Away' else Break()"
- { v: 16 }
- rules:
- x: "Next() if heating_mode() != 'Home' else Break()"
Check you config and reboot
You should now have a climate.xxxxx entity you can add to your lovelace ui.
As I use the cloud: component, it adds the climate.xxx device to Alexa (in my case) which adds voice control of each heater which are configured in alexa on a per heater to seperate rooms which have an echo dot per room thus allowing you to say “Alexa, Turn up the heating by 1 degree” etc in each room.
Schedy will also be monitoring each climate.xxx heater and depending on the “resceduling_delay” will reset to the normal sceduled temp if controlled via the UI or iOS app
Hope this helps anyone looking to do similar
I will post a link to my full config in due time on guthub
Matthew