diff --git a/.drone.yml b/.drone.yml index bd65d1a..1017140 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,28 +1,60 @@ +--- +kind: pipeline +type: docker +name: pull_request +image_pull_secrets: + - dockerconfigjson + +steps: + - name: lint yaml + image: registry.fedy95.com/baseimage-yamllint:latest + commands: + - yamllint -c /yamllint/relaxed.yaml etc/config/blueprints/automation/homeassistant/motion_light.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/custom_components/circadian_lighting/services.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/automations.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/configuration.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/groups.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/recorder.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/scenes.yaml + - yamllint -c /yamllint/relaxed.yaml etc/config/scripts.yaml + - yamllint -c /yamllint/relaxed.yaml docker-compose.yml + when: + event: pull_request + - name: lint json + image: registry.fedy95.com/baseimage-jsonlint:latest + commands: + - jsonlint -qc etc/config/custom_components/circadian_lighting/manifest.json + when: + event: pull_request + +--- kind: pipeline type: ssh -name: default +name: master_push clone: - disable: true + disable: true server: - host: - from_secret: host - user: - from_secret: user - password: - from_secret: password + host: + from_secret: host + user: + from_secret: user + password: + from_secret: password steps: - - name: release - commands: - - cd /mnt/md0/infra/homeassistant - - git pull - - make restart - - make check + - name: release + commands: + - cd /mnt/md0/infra/homeassistant + - git pull + - make restart + - make check trigger: - branch: - - master - event: - - push + branch: + - master + event: + - push +... diff --git a/.editorconfig b/.editorconfig index 38fe478..73069d4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,10 @@ root = true [*] -end_of_line = lf -insert_final_newline = true charset = utf-8 - -[*.json] +end_of_line = lf indent_style = space -indent_size = 4 +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 100 diff --git a/Makefile b/Makefile index b6faa42..3c5ab02 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,38 @@ MAKEFLAGS += --silent - .PHONY: * +REGISTRY=registry.fedy95.com +YAMLLINT_TAG=baseimage-yamllint:latest +JSONLINT_TAG=baseimage-jsonlint:latest + +lint: lint-yaml lint-json + +LINT-YAML-CMD=docker run --rm -it -v $(PWD):/data ${REGISTRY}/${YAMLLINT_TAG} +lint-yaml: + docker pull ${REGISTRY}/${YAMLLINT_TAG} + $(LINT-YAML-CMD) etc/config/blueprints/automation/homeassistant/motion_light.yaml + $(LINT-YAML-CMD) etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml + $(LINT-YAML-CMD) etc/config/custom_components/circadian_lighting/services.yaml + $(LINT-YAML-CMD) etc/config/automations.yaml + $(LINT-YAML-CMD) etc/config/configuration.yaml + $(LINT-YAML-CMD) etc/config/groups.yaml + $(LINT-YAML-CMD) etc/config/recorder.yaml + $(LINT-YAML-CMD) etc/config/scenes.yaml + $(LINT-YAML-CMD) etc/config/scripts.yaml + $(LINT-YAML-CMD) docker-compose.yml + +LINT-JSON-CMD=docker run --rm -it -v $(PWD):/data ${REGISTRY}/${JSONLINT_TAG} +lint-json: + docker pull ${REGISTRY}/${JSONLINT_TAG} + $(LINT-JSON-CMD) -qc etc/config/custom_components/circadian_lighting/manifest.json + +restart: down start start: docker-compose -f docker-compose.yml up -d down: docker-compose -f docker-compose.yml down -restart: down start - check: docker exec homeassistant_instance python -m homeassistant --script check_config --config /config -.DEFAULT_GOAL := restart +.DEFAULT_GOAL := lint diff --git a/docker-compose.yml b/docker-compose.yml index 76f3298..433060b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +--- version: "3" services: @@ -27,3 +28,4 @@ services: volumes: - ./etc/homeassistant_db/data:/var/lib/mysql +... diff --git a/etc/config/automations.yaml b/etc/config/automations.yaml index fe51488..c5ae665 100644 --- a/etc/config/automations.yaml +++ b/etc/config/automations.yaml @@ -1 +1,3 @@ -[] +--- +[ ] +... diff --git a/etc/config/blueprints/automation/homeassistant/motion_light.yaml b/etc/config/blueprints/automation/homeassistant/motion_light.yaml index c11d22d..e751c98 100644 --- a/etc/config/blueprints/automation/homeassistant/motion_light.yaml +++ b/etc/config/blueprints/automation/homeassistant/motion_light.yaml @@ -1,3 +1,4 @@ +--- blueprint: name: Motion-activated Light description: Turn on a light when motion is detected. @@ -48,3 +49,4 @@ action: - delay: !input no_motion_wait - service: light.turn_off target: !input light_target +... diff --git a/etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml b/etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml index d3a70d7..8ee024b 100644 --- a/etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml +++ b/etc/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml @@ -1,3 +1,4 @@ +--- blueprint: name: Zone Notification description: Send a notification to a device when a person leaves a specific zone. @@ -41,3 +42,4 @@ action: type: notify device_id: !input notify_device message: "{{ person_name }} has left {{ zone_state }}" +... diff --git a/etc/config/configuration.yaml b/etc/config/configuration.yaml index a186d4c..ea6a3e1 100644 --- a/etc/config/configuration.yaml +++ b/etc/config/configuration.yaml @@ -1,18 +1,19 @@ +--- homeassistant: - name: Home Assistant KR - latitude: !secret latitude_home - longitude: !secret longitude_home - elevation: !secret elevation_home - temperature_unit: C - time_zone: Europe/Moscow - unit_system: metric + name: Home Assistant KR + latitude: !secret latitude_home + longitude: !secret longitude_home + elevation: !secret elevation_home + temperature_unit: C + time_zone: Europe/Moscow + unit_system: metric zone: - - name: Home - latitude: !secret latitude_home - longitude: !secret longitude_home - radius: 200 - icon: mdi:home + - name: Home + latitude: !secret latitude_home + longitude: !secret longitude_home + radius: 200 + icon: mdi:home default_config: @@ -24,55 +25,55 @@ script: !include scripts.yaml # https://www.home-assistant.io/integrations/yeelight yeelight: - devices: - 10.10.10.10: - name: Room unit0 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.11: - name: Room unit1 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.12: - name: Room unit2 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.13: - name: Room unit3 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.14: - name: Room unit4 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.15: - name: Room unit5 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.16: - name: Room unit6 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 - 10.10.10.17: - name: Room unit7 - transition: 1000 - use_music_mode: false - save_on_change: false - model: color4 + devices: + 10.10.10.10: + name: Room unit0 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.11: + name: Room unit1 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.12: + name: Room unit2 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.13: + name: Room unit3 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.14: + name: Room unit4 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.15: + name: Room unit5 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.16: + name: Room unit6 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 + 10.10.10.17: + name: Room unit7 + transition: 1000 + use_music_mode: false + save_on_change: false + model: color4 # https://github.com/claytonjn/hass-circadian_lighting circadian_lighting: @@ -101,3 +102,4 @@ light: - light.room_unit5 - light.room_unit6 - light.room_unit7 +... diff --git a/etc/config/custom_components/circadian_lighting/manifest.json b/etc/config/custom_components/circadian_lighting/manifest.json index 4832a25..e487f3e 100644 --- a/etc/config/custom_components/circadian_lighting/manifest.json +++ b/etc/config/custom_components/circadian_lighting/manifest.json @@ -3,6 +3,10 @@ "name": "Circadian Lighting", "documentation": "https://github.com/claytonjn/hass-circadian_lighting", "dependencies": [], - "codeowners": ["@claytonjn"], - "requirements": ["timezonefinder==4.2.0"] + "codeowners": [ + "@claytonjn" + ], + "requirements": [ + "timezonefinder==4.2.0" + ] } diff --git a/etc/config/custom_components/circadian_lighting/services.yaml b/etc/config/custom_components/circadian_lighting/services.yaml index 586f06e..756664b 100644 --- a/etc/config/custom_components/circadian_lighting/services.yaml +++ b/etc/config/custom_components/circadian_lighting/services.yaml @@ -1,2 +1,4 @@ +--- values_update: description: Updates values for Circadian Lighting. +... diff --git a/etc/config/groups.yaml b/etc/config/groups.yaml index e69de29..91da2a7 100644 --- a/etc/config/groups.yaml +++ b/etc/config/groups.yaml @@ -0,0 +1,2 @@ +--- +... diff --git a/etc/config/recorder.yaml b/etc/config/recorder.yaml index 241f71a..eebaa9d 100644 --- a/etc/config/recorder.yaml +++ b/etc/config/recorder.yaml @@ -1 +1,3 @@ +--- db_url: !secret recorder_db_url +... diff --git a/etc/config/scenes.yaml b/etc/config/scenes.yaml index e69de29..91da2a7 100644 --- a/etc/config/scenes.yaml +++ b/etc/config/scenes.yaml @@ -0,0 +1,2 @@ +--- +... diff --git a/etc/config/scripts.yaml b/etc/config/scripts.yaml index e69de29..91da2a7 100644 --- a/etc/config/scripts.yaml +++ b/etc/config/scripts.yaml @@ -0,0 +1,2 @@ +--- +...