From 712ad45cacde73d376fa7b025d06c28d783dfa4c Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Aug 2021 08:07:36 +0200 Subject: [PATCH] Adding GitHub checkrun sensors and MQTT save #21 --- .HA_VERSION | 2 +- .github/workflows/main.yml | 23 +++++ .../system/github_actions_webhook.yaml | 30 ++++++ entities/rest_command/github_actions.yaml | 2 +- .../github_checkrun_home_assistant_beta.yaml | 11 +++ ...ithub_checkrun_home_assistant_current.yaml | 11 +++ .../github_checkrun_home_assistant_dev.yaml | 11 +++ ...github_checkrun_home_assistant_stable.yaml | 11 +++ .../system/github_checkrun_remarklint.yaml | 11 +++ .../system/github_checkrun_yamllint.yaml | 11 +++ python_scripts/shellies_discovery.py | 94 ++++++++++++------- secrets_github.yaml | 1 + secrets_sample.yaml | 1 + 13 files changed, 185 insertions(+), 34 deletions(-) create mode 100644 automations/system/github_actions_webhook.yaml create mode 100644 entities/sensors/system/github_checkrun_home_assistant_beta.yaml create mode 100644 entities/sensors/system/github_checkrun_home_assistant_current.yaml create mode 100644 entities/sensors/system/github_checkrun_home_assistant_dev.yaml create mode 100644 entities/sensors/system/github_checkrun_home_assistant_stable.yaml create mode 100644 entities/sensors/system/github_checkrun_remarklint.yaml create mode 100644 entities/sensors/system/github_checkrun_yamllint.yaml diff --git a/.HA_VERSION b/.HA_VERSION index ddfcf482..a77cee31 100644 --- a/.HA_VERSION +++ b/.HA_VERSION @@ -1 +1 @@ -2021.7.4 \ No newline at end of file +2021.8.0 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c14227f..2d855d75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,6 +30,29 @@ jobs: continue-on-error: true with: args: "remark --no-stdout --color --frail --use preset-lint-recommended ." + home_assistant_current: + runs-on: ubuntu-latest + needs: [yamllint, remarklint] + steps: + - name: Getting your configuration from GitHub + uses: actions/checkout@v1 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Copy stub files into configuration folder + run: | + cp -R secrets_github.yaml secrets.yaml + cp -R customize_sample.yaml customize.yaml + cp -R 0d25726f0c18_sample.json 0d25726f0c18.json + sudo mkdir -p /github/workspace/tmp + #sudo touch fullchain.pem + #sudo touch privkey.pem + HA_VERSION=$(<.HA_VERSION) + - name: Install Home Assistant + run: pip3 install homeassistant==$(cat .HA_VERSION) + - name: Check config + run: hass -c . --script check_config --info all home_assistant_stable: runs-on: ubuntu-latest needs: [yamllint, remarklint] diff --git a/automations/system/github_actions_webhook.yaml b/automations/system/github_actions_webhook.yaml new file mode 100644 index 00000000..60ff6003 --- /dev/null +++ b/automations/system/github_actions_webhook.yaml @@ -0,0 +1,30 @@ +##### +# +# +##### + +alias: github actions webhook +id: 'b70b316f-bf5a-4618-95c3-8594cd290b3a' + +mode: queued + +trigger: + platform: webhook + webhook_id: !secret github_actions_webhook + +condition: '{{trigger.json.check_run.check_suite.head_branch == "master"}}' + +action: +- service: mqtt.publish + data: + topic: 'github_checkrun/{{ trigger.json.check_run.name}}' + payload: > + {"status": {%- if trigger.json.check_run.status == 'completed' -%} + "{{trigger.json.check_run.conclusion}}" + {%- else -%} + "{{trigger.json.check_run.status}}" + {%- endif -%}, "id": "{{trigger.json.check_run.id + }}", "started_at": "{{trigger.json.check_run.started_at + }}", "completed_at": "{{trigger.json.check_run.completed_at + }}", "details_url": "{{trigger.json.check_run.details_url}}"} + retain: true \ No newline at end of file diff --git a/entities/rest_command/github_actions.yaml b/entities/rest_command/github_actions.yaml index 142a8b8a..08451ed4 100644 --- a/entities/rest_command/github_actions.yaml +++ b/entities/rest_command/github_actions.yaml @@ -4,7 +4,7 @@ ##### github_actions: - url: https://api.github.com/BeardedTinker/Home-Assistant_Config/actions/workflows/main.yml/dispatches + url: https://api.github.com/repos/BeardedTinker/Home-Assistant_Config/actions/workflows/main.yml/dispatches method: POST headers: authorization: !secret github_token2 diff --git a/entities/sensors/system/github_checkrun_home_assistant_beta.yaml b/entities/sensors/system/github_checkrun_home_assistant_beta.yaml new file mode 100644 index 00000000..72ad4934 --- /dev/null +++ b/entities/sensors/system/github_checkrun_home_assistant_beta.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - Home Assistant beta release +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_home_assistant_beta +state_topic: github_checkrun/home_assistant_beta +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/home_assistant_beta +icon: mdi:github diff --git a/entities/sensors/system/github_checkrun_home_assistant_current.yaml b/entities/sensors/system/github_checkrun_home_assistant_current.yaml new file mode 100644 index 00000000..cc6b5a31 --- /dev/null +++ b/entities/sensors/system/github_checkrun_home_assistant_current.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - Home Assistant curent release +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_home_assistant_current +state_topic: github_checkrun/home_assistant_current +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/home_assistant_current +icon: mdi:github diff --git a/entities/sensors/system/github_checkrun_home_assistant_dev.yaml b/entities/sensors/system/github_checkrun_home_assistant_dev.yaml new file mode 100644 index 00000000..f0637b63 --- /dev/null +++ b/entities/sensors/system/github_checkrun_home_assistant_dev.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - Home Assistant dev release +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_home_assistant_dev +state_topic: github_checkrun/home_assistant_dev +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/home_assistant_dev +icon: mdi:github \ No newline at end of file diff --git a/entities/sensors/system/github_checkrun_home_assistant_stable.yaml b/entities/sensors/system/github_checkrun_home_assistant_stable.yaml new file mode 100644 index 00000000..dc29d371 --- /dev/null +++ b/entities/sensors/system/github_checkrun_home_assistant_stable.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - Home Assistant Latest release +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_home_assistant_stable +state_topic: github_checkrun/home_assistant_stable +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/home_assistant_stable +icon: mdi:github diff --git a/entities/sensors/system/github_checkrun_remarklint.yaml b/entities/sensors/system/github_checkrun_remarklint.yaml new file mode 100644 index 00000000..24e5158c --- /dev/null +++ b/entities/sensors/system/github_checkrun_remarklint.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - remarklint +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_remarklint +state_topic: github_checkrun/remarklint +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/remarklint +icon: mdi:github diff --git a/entities/sensors/system/github_checkrun_yamllint.yaml b/entities/sensors/system/github_checkrun_yamllint.yaml new file mode 100644 index 00000000..1479ca80 --- /dev/null +++ b/entities/sensors/system/github_checkrun_yamllint.yaml @@ -0,0 +1,11 @@ +##### +# Populate data from Checkrun - yamlint +# By PinkyWafer - https://github.com/pinkywafer/Home-Assistant_Config/ +##### + +platform: mqtt +name: github_checkrun_yamllint +state_topic: github_checkrun/yamllint +value_template: "{{ value_json.status }}" +json_attributes_topic: github_checkrun/yamllint +icon: mdi:github diff --git a/python_scripts/shellies_discovery.py b/python_scripts/shellies_discovery.py index 1c0df57f..56bbf90f 100644 --- a/python_scripts/shellies_discovery.py +++ b/python_scripts/shellies_discovery.py @@ -91,6 +91,8 @@ KEY_IDENTIFIERS = "ids" KEY_JSON_ATTRIBUTES_TEMPLATE = "json_attr_tpl" KEY_JSON_ATTRIBUTES_TOPIC = "json_attr_t" +KEY_LAST_RESET_TOPIC = "lrst_t" +KEY_LAST_RESET_VALUE_TEMPLATE = "lrst_val_tpl" KEY_MANUFACTURER = "mf" KEY_MODEL = "mdl" KEY_NAME = "name" @@ -128,7 +130,7 @@ LIGHT_WHITE = "white" # Maximum light transition time in seconds -MAX_TRANSITION = 5 +MAX_TRANSITION = 4 # Firmware 1.6.5 release date MIN_4PRO_FIRMWARE_DATE = 20200408 @@ -372,6 +374,10 @@ TPL_HUMIDITY_EXT = "{%if value!=999%}{{value|float|round(1)}}{%endif%}" TPL_ILLUMINATION = "{{value_json.lux}}" TPL_ILLUMINATION_TO_JSON = "{{{^illumination^:value}|tojson}}" +TPL_LAST_RESET = "{{0|timestamp_utc}}" +TPL_LAST_RESET_FROM_UPTIME = ( + "{{(as_timestamp(utcnow())-value_json.uptime)|timestamp_utc}}" +) TPL_LONGPUSH = "{%if value_json.event==^L^%}ON{%else%}OFF{%endif%}" TPL_LONGPUSH_SHORTPUSH = "{%if value_json.event==^LS^%}ON{%else%}OFF{%endif%}" TPL_LUX = "{{value|float|round}}" @@ -556,8 +562,8 @@ def mqtt_publish(topic, payload, retain): ) if ( - dev_id_prefix not in [MODEL_SHELLY4PRO_PREFIX, MODEL_SHELLYMOTION_PREFIX] - and model_id not in [MODEL_SHELLY4PRO_ID, MODEL_SHELLYMOTION_ID] + dev_id_prefix not in (MODEL_SHELLY4PRO_PREFIX, MODEL_SHELLYMOTION_PREFIX) + and model_id not in (MODEL_SHELLY4PRO_ID, MODEL_SHELLYMOTION_ID) ) and cur_ver_date < MIN_FIRMWARE_DATE: raise ValueError( f"Firmware dated {MIN_FIRMWARE_DATE} is required, please update your device {dev_id}" @@ -568,7 +574,7 @@ def mqtt_publish(topic, payload, retain): ) # noqa: F821 try: - if int(data.get(CONF_QOS, 0)) in [0, 1, 2]: # noqa: F821 + if int(data.get(CONF_QOS, 0)) in (0, 1, 2): # noqa: F821 qos = int(data.get(CONF_QOS, 0)) # noqa: F821 else: raise ValueError() @@ -1022,7 +1028,7 @@ def mqtt_publish(topic, payload, retain): bin_sensors_topics = [TOPIC_INFO] if ( - model_id in [MODEL_SHELLYPLUG_ID, MODEL_SHELLYPLUG_E_ID] + model_id in (MODEL_SHELLYPLUG_ID, MODEL_SHELLYPLUG_E_ID) or dev_id_prefix == MODEL_SHELLYPLUG_PREFIX ): model = MODEL_SHELLYPLUG @@ -1342,7 +1348,7 @@ def mqtt_publish(topic, payload, retain): bin_sensors_topics = [TOPIC_INFO, None] if ( - model_id in [MODEL_SHELLYBUTTON1_ID, MODEL_SHELLYBUTTON1V2_ID] + model_id in (MODEL_SHELLYBUTTON1_ID, MODEL_SHELLYBUTTON1V2_ID) or dev_id_prefix == MODEL_SHELLYBUTTON1_PREFIX ): model = MODEL_SHELLYBUTTON1 @@ -1567,7 +1573,7 @@ def mqtt_publish(topic, payload, retain): battery_powered = True if model_id == MODEL_SHELLYRGBW2_ID or dev_id_prefix == MODEL_SHELLYRGBW2_PREFIX: - if mode not in [LIGHT_COLOR, LIGHT_WHITE]: + if mode not in (LIGHT_COLOR, LIGHT_WHITE): raise ValueError(f"mode value {mode} is not valid, check script configuration") model = MODEL_SHELLYRGBW2 @@ -2431,6 +2437,9 @@ def mqtt_publish(topic, payload, retain): } if relays_sensors_state_classes[sensor_id]: payload[KEY_STATE_CLASS] = relays_sensors_state_classes[sensor_id] + if relays_sensors[sensor_id] == SENSOR_ENERGY: + payload[KEY_LAST_RESET_TOPIC] = f"~{TOPIC_INFO}" + payload[KEY_LAST_RESET_VALUE_TEMPLATE] = TPL_LAST_RESET_FROM_UPTIME else: payload = "" if dev_id.lower() in ignored: @@ -2475,6 +2484,11 @@ def mqtt_publish(topic, payload, retain): }, "~": default_topic, } + if relays_sensors_state_classes[sensor_id]: + payload[KEY_STATE_CLASS] = relays_sensors_state_classes[sensor_id] + if relays_sensors[sensor_id] == SENSOR_ENERGY: + payload[KEY_LAST_RESET_TOPIC] = f"~{TOPIC_INFO}" + payload[KEY_LAST_RESET_VALUE_TEMPLATE] = TPL_LAST_RESET_FROM_UPTIME else: payload = "" if dev_id.lower() in ignored: @@ -2519,7 +2533,7 @@ def mqtt_publish(topic, payload, retain): } if ( relays_bin_sensors[bin_sensor_id] - in [ + in ( SENSOR_LONGPUSH, SENSOR_LONGPUSH_0, SENSOR_LONGPUSH_1, @@ -2536,7 +2550,7 @@ def mqtt_publish(topic, payload, retain): SENSOR_TRIPLE_SHORTPUSH_0, SENSOR_TRIPLE_SHORTPUSH_1, SENSOR_TRIPLE_SHORTPUSH_2, - ] + ) and push_off_delay ): payload[KEY_OFF_DELAY] = OFF_DELAY @@ -2553,7 +2567,7 @@ def mqtt_publish(topic, payload, retain): ] if ( model - in [ + in ( MODEL_SHELLY1PM, MODEL_SHELLY2, MODEL_SHELLY25, @@ -2561,7 +2575,7 @@ def mqtt_publish(topic, payload, retain): MODEL_SHELLYPLUG, MODEL_SHELLYPLUG_S, MODEL_SHELLYPLUG_US, - ] + ) and relays_bin_sensors[bin_sensor_id] == SENSOR_OVERPOWER ): payload[ @@ -2590,7 +2604,7 @@ def mqtt_publish(topic, payload, retain): config_topic = f"{disc_prefix}/sensor/{dev_id}-{sensors[sensor_id]}/config" default_topic = f"shellies/{dev_id}/" availability_topic = "~online" - if sensors[sensor_id] in [SENSOR_RSSI, SENSOR_SSID, SENSOR_ADC, SENSOR_IP]: + if sensors[sensor_id] in (SENSOR_RSSI, SENSOR_SSID, SENSOR_ADC, SENSOR_IP): sensor_name = f"{device_name} {sensors[sensor_id].upper()}" else: sensor_name = f"{device_name} {sensors[sensor_id].title()}" @@ -2603,7 +2617,7 @@ def mqtt_publish(topic, payload, retain): config_component = COMP_SWITCH if ( - model in [MODEL_SHELLYBUTTON1, MODEL_SHELLYMOTION, MODEL_SHELLYSENSE] + model in (MODEL_SHELLYBUTTON1, MODEL_SHELLYMOTION, MODEL_SHELLYSENSE) and device_config.get(CONF_POWERED) == ATTR_POWER_AC ): battery_powered = False @@ -2654,20 +2668,20 @@ def mqtt_publish(topic, payload, retain): payload[KEY_ICON] = "mdi:timer-outline" elif sensors[sensor_id] == SENSOR_TEMPERATURE_STATUS: payload[KEY_ICON] = "mdi:thermometer" - if battery_powered and sensors[sensor_id] not in [ + if battery_powered and sensors[sensor_id] not in ( SENSOR_SSID, SENSOR_RSSI, SENSOR_UPTIME, SENSOR_IP, - ]: + ): payload[KEY_EXPIRE_AFTER] = expire_after if not battery_powered: payload[KEY_AVAILABILITY_TOPIC] = availability_topic payload[KEY_PAYLOAD_AVAILABLE] = VALUE_TRUE payload[KEY_PAYLOAD_NOT_AVAILABLE] = VALUE_FALSE if ( - model in [MODEL_SHELLYBUTTON1, MODEL_SHELLYSENSE, MODEL_SHELLYHT] - and sensors[sensor_id] in [SENSOR_RSSI, SENSOR_SSID, SENSOR_UPTIME] + model in (MODEL_SHELLYBUTTON1, MODEL_SHELLYSENSE, MODEL_SHELLYHT) + and sensors[sensor_id] in (SENSOR_RSSI, SENSOR_SSID, SENSOR_UPTIME) and device_config.get(CONF_POWERED) != ATTR_POWER_AC ): payload = "" @@ -2828,7 +2842,7 @@ def mqtt_publish(topic, payload, retain): if isinstance(device_config.get(CONF_PUSH_OFF_DELAY), bool): push_off_delay = device_config.get(CONF_PUSH_OFF_DELAY) if ( - model in [MODEL_SHELLYBUTTON1, MODEL_SHELLYMOTION, MODEL_SHELLYSENSE] + model in (MODEL_SHELLYBUTTON1, MODEL_SHELLYMOTION, MODEL_SHELLYSENSE) and device_config.get(CONF_POWERED) == ATTR_POWER_AC ): battery_powered = False @@ -2887,11 +2901,11 @@ def mqtt_publish(topic, payload, retain): else: payload[KEY_PAYLOAD_ON] = bin_sensors_pl[bin_sensor_id][VALUE_ON] payload[KEY_PAYLOAD_OFF] = bin_sensors_pl[bin_sensor_id][VALUE_OFF] - if battery_powered and bin_sensors[bin_sensor_id] not in [ + if battery_powered and bin_sensors[bin_sensor_id] not in ( SENSOR_FIRMWARE_UPDATE, SENSOR_OPENING, SENSOR_CLOUD, - ]: + ): payload[KEY_EXPIRE_AFTER] = expire_after if not battery_powered: payload[KEY_AVAILABILITY_TOPIC] = availability_topic @@ -2901,7 +2915,7 @@ def mqtt_publish(topic, payload, retain): payload[KEY_DEVICE_CLASS] = bin_sensors_device_classes[bin_sensor_id] if ( bin_sensors[bin_sensor_id] - in [ + in ( SENSOR_LONGPUSH, SENSOR_LONGPUSH_0, SENSOR_LONGPUSH_1, @@ -2918,7 +2932,7 @@ def mqtt_publish(topic, payload, retain): SENSOR_TRIPLE_SHORTPUSH_0, SENSOR_TRIPLE_SHORTPUSH_1, SENSOR_TRIPLE_SHORTPUSH_2, - ] + ) and push_off_delay ): payload[KEY_OFF_DELAY] = OFF_DELAY @@ -2929,7 +2943,7 @@ def mqtt_publish(topic, payload, retain): ): payload = "" if ( - model in [MODEL_SHELLYDW, MODEL_SHELLYDW2] + model in (MODEL_SHELLYDW, MODEL_SHELLYDW2) and bin_sensors[bin_sensor_id] == SENSOR_OPENING ): payload[KEY_FORCE_UPDATE] = str(True) @@ -3007,7 +3021,7 @@ def mqtt_publish(topic, payload, retain): '"mf":"' + ATTR_MANUFACTURER + '"},' '"~":"' + default_topic + '"}' ) - elif model in [MODEL_SHELLYBULB, MODEL_SHELLYBULBRGBW]: + elif model in (MODEL_SHELLYBULB, MODEL_SHELLYBULBRGBW): payload = ( '{"schema":"template",' '"name":"' + light_name + '",' @@ -3135,6 +3149,9 @@ def mqtt_publish(topic, payload, retain): } if lights_sensors_state_classes[sensor_id]: payload[KEY_STATE_CLASS] = lights_sensors_state_classes[sensor_id] + if lights_sensors[sensor_id] == SENSOR_ENERGY: + payload[KEY_LAST_RESET_TOPIC] = f"~{TOPIC_INFO}" + payload[KEY_LAST_RESET_VALUE_TEMPLATE] = TPL_LAST_RESET_FROM_UPTIME else: payload = "" if dev_id.lower() in ignored: @@ -3153,12 +3170,12 @@ def mqtt_publish(topic, payload, retain): else: light_name = f"{device_name} Light {light_id}" default_topic = f"shellies/{dev_id}/" - if model in [ + if model in ( MODEL_SHELLYDIMMER, MODEL_SHELLYDIMMER2, MODEL_SHELLYDUO, MODEL_SHELLYVINTAGE, - ]: + ): state_topic = f"~light/{light_id}/status" command_topic = f"~light/{light_id}/set" unique_id = f"{dev_id}-light-{light_id}".lower() @@ -3195,7 +3212,7 @@ def mqtt_publish(topic, payload, retain): '"mf":"' + ATTR_MANUFACTURER + '"},' '"~":"' + default_topic + '"}' ) - elif model in [MODEL_SHELLYDIMMER, MODEL_SHELLYDIMMER2]: + elif model in (MODEL_SHELLYDIMMER, MODEL_SHELLYDIMMER2): payload = ( '{"schema":"template",' '"name":"' + light_name + '",' @@ -3347,12 +3364,12 @@ def mqtt_publish(topic, payload, retain): unique_id = f"{dev_id}-white-{lights_sensors[sensor_id]}-{light_id}".lower() config_topic = f"{disc_prefix}/sensor/{dev_id}-white-{lights_sensors[sensor_id]}-{light_id}/config" sensor_name = f"{device_name} {lights_sensors[sensor_id].title()} {light_id}" - if model in [ + if model in ( MODEL_SHELLYDIMMER, MODEL_SHELLYDIMMER2, MODEL_SHELLYDUO, MODEL_SHELLYVINTAGE, - ]: + ): state_topic = f"~light/{light_id}/{lights_sensors[sensor_id]}" elif model == MODEL_SHELLYRGBW2: state_topic = f"~white/{light_id}/{lights_sensors[sensor_id]}" @@ -3360,13 +3377,13 @@ def mqtt_publish(topic, payload, retain): state_topic = f"~white/{light_id}/status" if ( model - in [ + in ( MODEL_SHELLYDIMMER, MODEL_SHELLYDIMMER2, MODEL_SHELLYDUO, MODEL_SHELLYVINTAGE, MODEL_SHELLYRGBW2, - ] + ) and mode != LIGHT_COLOR ): payload = { @@ -3392,6 +3409,9 @@ def mqtt_publish(topic, payload, retain): } if lights_sensors_state_classes[sensor_id]: payload[KEY_STATE_CLASS] = lights_sensors_state_classes[sensor_id] + if lights_sensors[sensor_id] == SENSOR_ENERGY: + payload[KEY_LAST_RESET_TOPIC] = f"~{TOPIC_INFO}" + payload[KEY_LAST_RESET_VALUE_TEMPLATE] = TPL_LAST_RESET_FROM_UPTIME else: payload = "" if dev_id.lower() in ignored: @@ -3437,10 +3457,20 @@ def mqtt_publish(topic, payload, retain): }, "~": default_topic, } + if meters_sensors[sensor_id] in ( + SENSOR_ENERGY, + SENSOR_RETURNED_ENERGY, + SENSOR_TOTAL, + SENSOR_TOTAL_RETURNED, + ): + payload[KEY_LAST_RESET_TOPIC] = state_topic + payload[KEY_LAST_RESET_VALUE_TEMPLATE] = TPL_LAST_RESET if meters_sensors_state_classes[sensor_id]: payload[KEY_STATE_CLASS] = meters_sensors_state_classes[sensor_id] if meters_sensors_device_classes and meters_sensors_device_classes[sensor_id]: payload[KEY_DEVICE_CLASS] = meters_sensors_device_classes[sensor_id] if dev_id.lower() in ignored: payload = "" - mqtt_publish(config_topic, str(payload).replace("'", '"'), retain) + mqtt_publish( + config_topic, str(payload).replace("'", '"').replace("^", "'"), retain + ) diff --git a/secrets_github.yaml b/secrets_github.yaml index 94cd5452..513ab4f6 100644 --- a/secrets_github.yaml +++ b/secrets_github.yaml @@ -182,6 +182,7 @@ github_token: 00000000000000000000 github_token2: Bearer 00000000000000000000 github_token3: Bearer 00000000000000000000 github_webhook: 00000000000000000000 +github_actions_webhook: 00000000000000000000 # Travis travis_api_key: "token 00000000000000000000" diff --git a/secrets_sample.yaml b/secrets_sample.yaml index 2383ea30..5739fbac 100644 --- a/secrets_sample.yaml +++ b/secrets_sample.yaml @@ -182,6 +182,7 @@ github_token: 00000000000000000000 github_token2: Bearer 00000000000000000000 github_token3: Bearer 00000000000000000000 github_webhook: 00000000000000000000 +github_actions_webhook: 000000000000000000 # Travis travis_api_key: "token 00000000000000000000"