mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-02 10:01:37 +00:00
feat: Allow Home Assistant OTA Update entity to show progress while updating (#25632)
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
@@ -1405,16 +1405,12 @@ export default class HomeAssistant extends Extension {
|
||||
discovery_payload: {
|
||||
name: null,
|
||||
entity_picture: 'https://github.com/Koenkk/zigbee2mqtt/raw/master/images/logo.png',
|
||||
latest_version_topic: true,
|
||||
state_topic: true,
|
||||
device_class: 'firmware',
|
||||
entity_category: 'config',
|
||||
command_topic: `${settings.get().mqtt.base_topic}/bridge/request/device/ota_update/update`,
|
||||
payload_install: `{"id": "${entity.ieeeAddr}"}`,
|
||||
value_template: `{{ value_json['update']['installed_version'] }}`,
|
||||
latest_version_template: `{{ value_json['update']['latest_version'] }}`,
|
||||
json_attributes_topic: `${settings.get().mqtt.base_topic}/${entity.name}`, // state topic
|
||||
json_attributes_template: `{"in_progress": {{ iif(value_json['update']['state'] == 'updating', 'true', 'false') }} }`,
|
||||
value_template: `{"latest_version":"{{ value_json['update']['latest_version'] }}","installed_version":"{{ value_json['update']['installed_version'] }}","update_percentage":{{ value_json['update'].get('progress', 'null') }}}`,
|
||||
},
|
||||
};
|
||||
configs.push(updateSensor);
|
||||
@@ -1607,10 +1603,6 @@ export default class HomeAssistant extends Extension {
|
||||
payload.fan_mode_state_topic = stateTopic;
|
||||
}
|
||||
|
||||
if (payload.latest_version_topic) {
|
||||
payload.latest_version_topic = stateTopic;
|
||||
}
|
||||
|
||||
if (payload.fan_mode_command_topic) {
|
||||
payload.fan_mode_command_topic = `${baseTopic}/${commandTopicPrefix}set/fan_mode`;
|
||||
}
|
||||
|
||||
@@ -1674,17 +1674,14 @@ describe('Extension: HomeAssistant', () => {
|
||||
device_class: 'firmware',
|
||||
entity_category: 'config',
|
||||
entity_picture: 'https://github.com/Koenkk/zigbee2mqtt/raw/master/images/logo.png',
|
||||
json_attributes_template: `{"in_progress": {{ iif(value_json['update']['state'] == 'updating', 'true', 'false') }} }`,
|
||||
json_attributes_topic: 'zigbee2mqtt/bulb',
|
||||
latest_version_template: "{{ value_json['update']['latest_version'] }}",
|
||||
latest_version_topic: 'zigbee2mqtt/bulb',
|
||||
name: null,
|
||||
object_id: 'bulb',
|
||||
origin,
|
||||
payload_install: `{"id": "0x000b57fffec6a5b2"}`,
|
||||
state_topic: 'zigbee2mqtt/bulb',
|
||||
unique_id: '0x000b57fffec6a5b2_update_zigbee2mqtt',
|
||||
value_template: "{{ value_json['update']['installed_version'] }}",
|
||||
value_template:
|
||||
"{\"latest_version\":\"{{ value_json['update']['latest_version'] }}\",\"installed_version\":\"{{ value_json['update']['installed_version'] }}\",\"update_percentage\":{{ value_json['update'].get('progress', 'null') }}}",
|
||||
};
|
||||
|
||||
expect(mockMQTTPublishAsync).toHaveBeenCalledWith('homeassistant/update/0x000b57fffec6a5b2/update/config', stringify(payload), {
|
||||
|
||||
Reference in New Issue
Block a user