Hi,
now that version 12 is here, I have to convert a mammoth script of MQTT sensors from platform mode.
Trouble is, it seems to depend on platform statistics too!
Are there any HA yaml gurus who’d be willing to look at this and give me a clue?
I’d be REALLY grateful!
I think the worst bit is that the MQTT sensor seems to get its entity_id from the Statistics statement, but it’s all very confusing. (It was inherited as part of a non-supported package)
Thanks!
etrv_bedroom:
sensor:
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Temperature/8163"
name: "Bedroom Temperature"
unit_of_measurement: "°C"
force_update: true
expire_after: 660
- platform: mqtt
state_topic: "/energenie/eTRV/Report/TargetTemperature/8163"
name: "Bedroom Target Rcvd"
unit_of_measurement: "°C"
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Voltage/8163"
name: "Bedroom TRV Voltage"
unit_of_measurement: V
force_update: true
- platform: mqtt
state_topic: "/energenie/eTRV/Command/ValveState/8163"
name: "command_valvestate_8163"
- platform: mqtt
state_topic: "/energenie/eTRV/Command/Temperature/8163"
name: "command_temperature_8163"
- platform: statistics
name: bedroom_etrv_stats
entity_id: sensor.bedroom_temperature
state_characteristic: mean
max_age:
minutes: 25
binary_sensor:
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV Motor current below expectation"
value_template: '{{ value_json["Motor current below expectation"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV Motor current always high"
value_template: '{{ value_json["Motor current always high"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV Motor taking too long"
value_template: '{{ value_json["Motor taking too long"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV discrepancy between air and pipe sensors"
value_template: '{{ value_json["discrepancy between air and pipe sensors"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV air sensor out of expected range"
value_template: '{{ value_json["air sensor out of expected range"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV pipe sensor out of expected range"
value_template: '{{ value_json["pipe sensor out of expected range"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV Low Power Mode Enabled"
value_template: '{{ value_json["low power mode is enabled"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV no target temperature has been set by host"
value_template: '{{ value_json["no target temperature has been set by host"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV valve may be sticking"
value_template: '{{ value_json["valve may be sticking"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV valve exercise was successful"
value_template: '{{ value_json["valve exercise was successful"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV valve exercise was unsuccessful"
value_template: '{{ value_json["valve exercise was unsuccessful"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV driver micro has suffered a watchdog reset and needs data refresh"
value_template: '{{ value_json["driver micro has suffered a watchdog reset and needs data refresh"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV driver micro has suffered a noise reset and needs data refresh"
value_template: '{{ value_json["driver micro has suffered a noise reset and needs data refresh"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV battery voltage has fallen below 2.2V and valve has been opened"
value_template: '{{ value_json["battery voltage has fallen below 2p2V and valve has been opened"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV request for heat messaging is enabled"
value_template: '{{ value_json["request for heat messaging is enabled"] }}'
payload_on: true
payload_off: false
- platform: mqtt
state_topic: "/energenie/eTRV/Report/Diagnostics/8163"
name: "Bedroom TRV request for heat"
value_template: '{{ value_json["request for heat"] }}'
payload_on: true
payload_off: false
switch:
- platform: mqtt
name: "Bedroom TRV Low Power Mode"
command_topic: "/energenie/eTRV/Command/PowerMode/8163"
state_topic: "/energenie/eTRV/Command/PowerMode/8163"
payload_on: 1
payload_off: 0
retain: true
input_number:
bedroom_temp:
name: Bedroom Temperature Target
min: 4
max: 30
step: 1
unit_of_measurement: "°C"
mode: slider
initial: 18
icon: mdi:thermometer-lines
input_select:
bedroom_trv_state:
name: Bedroom TRV Valve State
options:
- Closed
- Normal
- Open
script:
send_report_voltage_bedroom:
sequence:
- service: script.send_trv_command
data:
id: '8163'
command: 'Voltage'
send_report_diagnostics_bedroom:
sequence:
- service: script.send_trv_command
data:
id: '8163'
command: 'Diagnostics'
send_exercise_bedroom:
sequence:
- service: script.send_trv_command
data:
id: '8163'
command: 'Exercise'
send_identity_bedroom:
sequence:
# This is written using the Script Syntax
- service: script.send_trv_command
data:
id: '8163'
command: 'Identify'
group:
bedroom_trv:
entities:
- sensor.bedroom_temperature
- input_number.bedroom_temp
- sensor.bedroom_target_rcvd
- input_select.bedroom_trv_state
- switch.bedroom_trv_low_power_mode
- script.send_report_diagnostics_bedroom
- script.send_exercise_bedroom
- script.send_identity_bedroom
- script.send_report_voltage_bedroom
- sensor.bedroom_trv_voltage
bedroom_diagnostics:
entities:
- binary_sensor.bedroom_trv_motor_current_below_expectation
- binary_sensor.bedroom_trv_motor_current_always_high
- binary_sensor.bedroom_trv_motor_taking_too_long
- binary_sensor.bedroom_trv_discrepancy_between_air_and_pipe_sensors
- binary_sensor.bedroom_trv_air_sensor_out_of_expected_range
- binary_sensor.bedroom_trv_pipe_sensor_out_of_expected_range
- binary_sensor.bedroom_trv_low_power_mode_enabled
- binary_sensor.bedroom_trv_no_target_temperature_has_been_set_by_host
- binary_sensor.bedroom_trv_valve_may_be_sticking
- binary_sensor.bedroom_trv_valve_exercise_was_successful
- binary_sensor.bedroom_trv_valve_exercise_was_unsuccessful
- binary_sensor.bedroom_trv_driver_micro_has_suffered_a_watchdog_reset_and_needs_data_refresh
- binary_sensor.bedroom_trv_driver_micro_has_suffered_a_noise_reset_and_needs_data_refresh
- binary_sensor.bedroom_trv_battery_voltage_has_fallen_below_2_2v_and_valve_has_been_opened
- binary_sensor.bedroom_trv_request_for_heat_messaging_is_enabled
- binary_sensor.bedroom_trv_request_for_heat