From 9cf43de570d74077bbbaaeb2c85445135a9d835f Mon Sep 17 00:00:00 2001 From: Yonsm Date: Mon, 10 Apr 2023 17:22:24 +0800 Subject: [PATCH] Remove zhimqtt (error on 2023.4.1); Fix into mqtt.switch --- .HA_VERSION | 2 +- configuration.yaml | 2 +- extras/setup/HassFix.sh | 10 +++++++++- mqtt.yaml | 10 ++++++---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.HA_VERSION b/.HA_VERSION index 772ce94..16df2af 100644 --- a/.HA_VERSION +++ b/.HA_VERSION @@ -1 +1 @@ -2023.3.5 \ No newline at end of file +2023.4.1 \ No newline at end of file diff --git a/configuration.yaml b/configuration.yaml index 75aafcd..bd3f4a8 100755 --- a/configuration.yaml +++ b/configuration.yaml @@ -126,7 +126,7 @@ weather: name: 天气 #sensor: !include sensors.yaml -switch: !include switches.yaml +#switch: !include switches.yaml light: !include lights.yaml fan: !include fans.yaml mqtt: !include mqtt.yaml diff --git a/extras/setup/HassFix.sh b/extras/setup/HassFix.sh index f18592f..bad6865 100755 --- a/extras/setup/HassFix.sh +++ b/extras/setup/HassFix.sh @@ -1,6 +1,6 @@ #!/bin/sh -cd /usr/lib/python3.10/site-packages/homeassistant cd /usr/src/homeassistant/homeassistant +cd /usr/lib/python3.10/site-packages/homeassistant sed -i 's/_LOGGER.warning(CUSTOM_WARNING/#LOGGER.warning(CUSTOM_WARNING/' loader.py sed -i 's/minutes=30/days=30/' auth/const.py @@ -11,3 +11,11 @@ sed -i 's/Platform.BUTTON/#latform.BUTTON/' components/braviatv/__init__.py sed -i 's/f"{ATTR_MANUFACTURER} {model}"/model/' components/braviatv/entity.py sed -i 's/"RM4PRO", "RM4MINI"/"RM4PRO", "RMPRO", "RM4MINI"/' components/broadlink/sensor.py + +sed -i 's/await hass.config_entries.async_forward_entry_setups/#wait hass.config_entries.async_forward_entry_setups/' components/sun/__init__.py +sed -i 's/await hass.config_entries.async_unload_platforms/True or await hass.config_entries.async_unload_platforms/' components/sun/__init__.py + +grep 'CONF_ICON_TEMPLATE,' components/mqtt/switch.py || sed -i 's/CONF_VALUE_TEMPLATE,/CONF_VALUE_TEMPLATE, CONF_ICON_TEMPLATE,/' components/mqtt/switch.py +grep 'CONF_ICON_TEMPLATE)' components/mqtt/switch.py || sed -i 's/cv.template,/cv.template, vol.Optional(CONF_ICON_TEMPLATE): cv.template,/' components/mqtt/switch.py +grep '"original_state": m' components/mqtt/switch.py || sed -i 's/payload = self._value_template/if CONF_VALUE_TEMPLATE in self._config: self._attr_state_attributes = {"original_state": msg.payload}\n if CONF_ICON_TEMPLATE in self._config: self._attr_icon = self._config[CONF_ICON_TEMPLATE].async_render_with_possible_json_value(msg.payload)\n payload = self._value_template/' components/mqtt/switch.py +grep 'state_attributes(s,' components/mqtt/switch.py || sed -i 's/def _prepare_subscribe_topics/@property\n def state_attributes(self): return self._attr_state_attributes if hasattr(self, "_attr_state_attributes") else None\n\n def _prepare_subscribe_topics/' components/mqtt/switch.py diff --git a/mqtt.yaml b/mqtt.yaml index 0332ca8..ab826e4 100755 --- a/mqtt.yaml +++ b/mqtt.yaml @@ -123,10 +123,12 @@ switch: command_topic: Hassmart2/relay/1/set availability_topic: Hassmart2/status icon: mdi:fan - # - name: 浴室排气扇 - # state_topic: Hassmart3/relay/0 - # command_topic: Hassmart3/relay/0/set - # availability_topic: Hassmart3/status + - name: 书房音箱 + state_topic: NodeMCU2/relay/0 + command_topic: NodeMCU2/relay/0/set + availability_topic: NodeMCU2/status + value_template: '{% if value == "关闭" %}OFF{% else %}ON{% endif %}' + icon_template: '{% if value == "关闭" %}mdi:speaker-off{% elif value == "蓝牙" %}mdi:speaker-bluetooth{% elif value == "光纤" %}mdi:speaker-wireless{% elif value == "优盘" %}mdi:usb{% elif value == "辅助" %}mdi:video-input-component{% else %}mdi:speaker{% endif %}' light: - name: 客厅筒灯