commit b35d0126cf1991d595ddf256eb03afda86b51314
parent ada836a23e680f553b64b1dc8bd0468302e92d58
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 15:42:05 +0100
parent ada836a23e680f553b64b1dc8bd0468302e92d58
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 15:42:05 +0100
roles/smartied: update dependencys, generate config from yaml
6 files changed, 35 insertions(+), 181 deletions(-)
D
|
173
-------------------------------------------------------------------------------
diff --git a/config-files/smartied.json b/config-files/smartied.json @@ -1,173 +0,0 @@ -{ - "devices": { - "modbus-10": { - "type": "RelayBoard", - "firstRegister": 0, - "count": 4, - "address": 10 - }, - "modbus-20": { - "type": "RelayBoard", - "firstRegister": 0, - "count": 4, - "address": 20 - }, - "modbus-50": { - "type": "PowerMeter", - "model": "SDM120", - "address": 50 - }, - "modbus-60": { - "type": "PowerMeter", - "model": "SDM120", - "address": 60 - }, - "tradfri-lamp1": { - "type": "Zigbee2MqttLamp", - "lampType": "RGB", - "deviceName": "ikea_lamp_rgb" - }, - "tradfri-lamp2": { - "type": "Zigbee2MqttLamp", - "lampType": "WhiteSpectrum", - "deviceName": "ikea_lamp_whitespectrum" - }, - "tradfri-lamp3": { - "type": "Zigbee2MqttLamp", - "lampType": "Switchable", - "deviceName": "ikea_lamp_switchable" - }, - "tradfri-relay1": { - "type": "Zigbee2MqttRelay", - "deviceName": "ikea_control_outlet" - }, - "tradfri-remote1": { - "type": "Zigbee2MqttRemote", - "deviceName": "ikea_remote", - "actions": { - "toggle": {"type": "SwitchStateAction", "deviceName": "modbus-10", "relay": 0, "toggle": true}, - "toggle_hold": {"type": "SwitchStateAction", "deviceName": "modbus-10", "relay": 2, "toggle": true}, - "arrow_left_click": {"type": "SwitchStateAction", "deviceName": "modbus-10", "relay": 1, "toggle": true}, - "arrow_right_click": {"type": "SwitchStateAction", "deviceName": "modbus-10", "relay": 3, "toggle": true}, - "brightness_up_click": {"type": "SwitchStateAction", "deviceName": "modbus-20", "relay": 0, "toggle": true}, - "brightness_down_click": {"type": "SwitchStateAction", "deviceName": "modbus-20", "relay": 2, "toggle": true}, - "brightness_down_hold": {"type": "SwitchStateAction", "deviceName": "modbus-20", "relay": 3, "toggle": true} - } - }, - "lacrosse-raum": { - "type": "LacrosseTempSensor", - "id": "21" - }, - "lacrosse-kuehlschrank": { - "type": "LacrosseTempSensor", - "id": "3a" - }, - "lacrosse-draussen": { - "type": "LacrosseTempSensor", - "id": "26" - }, - "lacrosse-bad": { - "type": "LacrosseTempSensor", - "id": "3f" - } - }, - "clientConfigs": { - "smarthome-pwa": { - "views": [ - { - "url": "lights", - "name": "Lights", - "icon": "lightbulb", - "type": "switches", - "switches": [ - { "name": "Decke (abgedunkelt)", "device": "modbus-10", "relay": 0 }, - { "name": "Decke", "device": "modbus-10", "relay": 2 }, - { "name": "Küche", "device": "modbus-10", "relay": 1 }, - { "name": "Bett", "device": "modbus-10", "relay": 3 }, - { "name": "Bad", "device": "modbus-20", "relay": 0 }, - { "name": "Decke: RGB", "device": "tradfri-lamp1", "relay": 0 }, - { "name": "Decke: Weiß-Spektrum", "device": "tradfri-lamp2", "relay": 0 }, - { "name": "Decke: Schaltbar", "device": "tradfri-lamp3", "relay": 0 } - ] - }, - { - "url": "switches", - "name": "Switches", - "icon": "power_settings_new", - "type": "switches", - "switches": [ - { "name": "Lüfter", "device": "modbus-20", "relay": 3 }, - { "name": "Lüfter (leise)", "device": "modbus-20", "relay": 2 }, - { "name": "Tradfri Steckdose", "device": "tradfri-relay1", "relay": 0 }, - ] - }, - { - "url": "powermeter", - "name": "Power Meter", - "icon": "power", - "type": "powermeter", - "meters": [ - { "name": "Sonstiges", "device": "modbus-50" }, - { "name": "Küche", "device": "modbus-60" } - ] - }, - { - "url": "temperature", - "name": "Temperature", - "icon": "brightness_7", - "type": "temperature", - "sensors": [ - { "name": "Kühlschrank", "device": "lacrosse-kuehlschrank" }, - { "name": "Raum", "device": "lacrosse-raum" }, - { "name": "Bad", "device": "lacrosse-bad" }, - { "name": "Draussen", "device": "lacrosse-draussen" } - ] - }, - { - "url": "departures", - "name": "Departures", - "icon": "departure_board", - "type": "departures", - "source": "https://f2k1.de/haltestellen.php" - }, - { - "url": "fritzbox", - "name": "Fritz!Box", - "icon": "router", - "type": "redirect", - "destination": "http://192.168.178.1/" - }, - { - "url": "settings", - "name": "Settings", - "icon": "settings", - "type": "settings", - "sourceLink": "https://cgit.ctu.cx/smarthome-pwa" - } - ] - } - }, - "serverConfig": { - "frontendPort": 5000, - "modbus": { - "host": "10.0.0.1", - "port": 502 - }, - "mqtt": { - "host": "10.0.0.1", - "port": 1883 - }, - "lacrosse": { - "host": "10.0.0.1", - "port": 2342 - }, - "influx": { - "host": "10.0.0.1", - "port": 8086, - "powermetersDatabase": "powermeters", - "sensorsDatabase": "sensors" - }, - "powermeterUpdateIntervalSec": 20, - "accessToken": "penis123" - } -}
diff --git a/roles/smartied/files/smartied.service-override.conf b/roles/smartied/files/smartied.service-override.conf @@ -3,5 +3,5 @@ # [Unit] -Requires=network.target serial2tcp@tempsensors0.service mbusd.service mosquitto.service zigbee2mqtt.service influxdb.service -After=serial2tcp@tempsensors0.service mbusd.service mosquitto.service zigbee2mqtt.service influxdb.service- \ No newline at end of file +Requires=network.target serial2tcp.service mbusd.service mosquitto.service zigbee2mqtt.service influxdb.service +After=serial2tcp.service mbusd.service mosquitto.service zigbee2mqtt.service influxdb.service+ \ No newline at end of file
diff --git a/roles/smartied/meta/main.yml b/roles/smartied/meta/main.yml @@ -1,4 +1,9 @@ --- dependencies: + - role: influxdb + - role: mosquitto + - role: zigbee2mqtt + - role: mbusd + - role: serial2tcp - role: nginx
diff --git a/roles/smartied/tasks/checks.yml b/roles/smartied/tasks/checks.yml @@ -9,10 +9,30 @@ - system.enableOwnRepos is false -- fail: msg="Option 'services.smartied.configFile' has to be set!" +- fail: msg="This Role depends on influxdb!" when: - - services.smartied.configFile is not defined + - services.influxdb.enable is false +- fail: msg="This Role depends on serial2tcp!" + when: + - services.serial2tcp.enable is false + +- fail: msg="This Role depends on mosquitto!" + when: + - services.mosquitto.enable is false + +- fail: msg="This Role depends on zigbee2mqtt!" + when: + - services.zigbee2mqtt.enable is false + +- fail: msg="This Role depends on mbusd!" + when: + - services.mbusd.enable is false + + +- fail: msg="Option 'services.smartied.config' has to be set!" + when: + - services.smartied.config is not defined - fail: msg="Nginx role has to be enabled when using nginx options!" when:
diff --git a/roles/smartied/tasks/configure.yml b/roles/smartied/tasks/configure.yml @@ -1,8 +1,8 @@ --- -- name: "Copy config-file to: /etc/smartied.json" - copy: - src: "{{ services.smartied.configFile }}" +- name: "Generate config: /etc/smartied.json" + template: + src: smartied.json.j2 dest: /etc/smartied.json mode: 0755 notify: "Restart smartied"
diff --git a/roles/smartied/templates/smartied.json.j2 b/roles/smartied/templates/smartied.json.j2 @@ -0,0 +1 @@ +{{ services.smartied.config | to_json }}+ \ No newline at end of file