mirror of
https://github.com/RichieCahill/dotfiles.git
synced 2026-04-17 13:08:19 -04:00
created python heater to contron the hln heater
This commit is contained in:
33
systems/brain/services/heater.nix
Normal file
33
systems/brain/services/heater.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [ 8124 ];
|
||||
|
||||
systemd.services.heater-api = {
|
||||
description = "Tuya Heater Control API";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment = {
|
||||
PYTHONPATH = "${inputs.self}/";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.my_python}/bin/python -m python.heater.main --host 0.0.0.0 --port 8124";
|
||||
EnvironmentFile = "/etc/heater.env";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
NoNewPrivileges = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = "read-only";
|
||||
PrivateTmp = true;
|
||||
ReadOnlyPaths = [ "${inputs.self}" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
victron_modbuss = "!include ${./home_assistant/victron_modbuss.yaml}";
|
||||
battery_sensors = "!include ${./home_assistant/battery_sensors.yaml}";
|
||||
gps_location = "!include ${./home_assistant/gps_location.yaml}";
|
||||
heater = "!include ${./home_assistant/heater.yaml}";
|
||||
van_weather = "!include ${./home_assistant/van_weather_template.yaml}";
|
||||
};
|
||||
};
|
||||
@@ -71,6 +72,7 @@
|
||||
pymetno # for met.no weather
|
||||
uiprotect # for ubiquiti integration
|
||||
unifi-discovery # for ubiquiti integration
|
||||
jsonpath # for rest sensors
|
||||
];
|
||||
extraComponents = [ "isal" ];
|
||||
customComponents = with pkgs.home-assistant-custom-components; [
|
||||
|
||||
41
systems/brain/services/home_assistant/heater.yaml
Normal file
41
systems/brain/services/home_assistant/heater.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
rest:
|
||||
- resource: http://localhost:8124/status
|
||||
scan_interval: 30
|
||||
sensor:
|
||||
- name: "Heater Setpoint"
|
||||
unique_id: heater_setpoint
|
||||
value_template: "{{ value_json.setpoint }}"
|
||||
unit_of_measurement: "F"
|
||||
device_class: temperature
|
||||
- name: "Heater State"
|
||||
unique_id: heater_state
|
||||
value_template: "{{ value_json.state }}"
|
||||
- name: "Heater Error Code"
|
||||
unique_id: heater_error_code
|
||||
value_template: "{{ value_json.error_code }}"
|
||||
binary_sensor:
|
||||
- name: "Heater Power"
|
||||
unique_id: heater_power
|
||||
value_template: "{{ value_json.power }}"
|
||||
device_class: running
|
||||
|
||||
rest_command:
|
||||
heater_on:
|
||||
url: http://localhost:8124/on
|
||||
method: POST
|
||||
heater_off:
|
||||
url: http://localhost:8124/off
|
||||
method: POST
|
||||
heater_toggle:
|
||||
url: http://localhost:8124/toggle
|
||||
method: POST
|
||||
|
||||
template:
|
||||
- switch:
|
||||
- unique_id: heater_switch
|
||||
name: Heater
|
||||
state: "{{ is_state('binary_sensor.heater_power', 'on') }}"
|
||||
turn_on:
|
||||
- action: rest_command.heater_on
|
||||
turn_off:
|
||||
- action: rest_command.heater_off
|
||||
Reference in New Issue
Block a user