Skip to content

Commit

Permalink
Trial with binary_sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThermIQ committed Jan 7, 2024
1 parent 9179986 commit 98459a5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
26 changes: 16 additions & 10 deletions ThermIQ_Card.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ entities:
content: >
<style>
.hpwidget-val {width:35px;height:16px;background:#a0a0a0;text-align: center;color:white;border-radius: 0.25em;}
.hpwidget-vald {width:45px;height:16px;background:#ffffff;text-align: center;color:black;border-radius: 0.25em;}
.hpwidget-name-span{}
.hpwidget-unit-span{text-align:right;overflow:hidden;color:white;font-size:70%}
.hpwidget-unit-spand{text-align:right;overflow:hidden;color:black;font-size:70%}
@keyframes rotating {to { transform: rotate(1turn); }}
@keyframes blink { to {visibility: hidden;}}
</style>
<div style="height:330px;width:100%;{% if (states('sensor.thermiq_mqtt_vp1_alarm_indication_on')=='on') %}background-color:red;{% endif %}">
<div style="height:330px;width:100%;{% if (states('binary_sensor.thermiq_mqtt_vp1_alarm_indication_on')==true) %}background-color:red;{% endif %}">
<div style="position:absolute;left:130px;">
{% if states('sensor.thermiq_mqtt_vp1_hotwaterproduction_on')=='on' %}
{% if states('binary_sensor.thermiq_mqtt_vp1_hotwaterproduction_on')==true %}
<div><img class="hp_basepict hw" style="position:absolute;top:0px;left:0px;height:300px;" alt="vp missing" src="/local/community/vp_base_hw.jpg" title=""></div>
{% else %}
{% if (states('sensor.thermiq_mqtt_vp1_opt_hgw_installed')=='on') and (states('sensor.thermiq_mqtt_vp1_compressor_on')=='on') %}
{% if (states('binary_sensor.thermiq_mqtt_vp1_opt_hgw_installed')==true) and (states('binary_sensor.thermiq_mqtt_vp1_compressor_on')==true) %}
<div><img class="hp_basepict hgw" style="position:absolute;top:0px;left:0px;height:300px;" alt="vp missing" src="/local/community/vp_base_hgwon.jpg" title=""></div>
{% else %}
<div><img class="hp_basepict base active" style="position:absolute;top:0px;left:0px;height:300px;" alt="vp missing" src="/local/community/vp_base.jpg" title="ThermIQ"></div>
Expand All @@ -37,17 +39,21 @@ entities:
<div class="hpwidget-val" title="Boiler Temperature" style="position:absolute;top:89px;left:138px;z-index:3;"><span class="hpwidget-name-span" id="hpwidget-T_VATTEN"></span>{{ states('sensor.thermiq_mqtt_vp1_boiler_t') }}<span class="hpwidget-unit-span">&nbsp;C</span></div>
<div class="hpwidget-val" title="HGW Temperature" style="position:absolute;top:87px;left:76px;z-index:3; <span class="hpwidget-name-span" id="hpwidget-HGW_VV"></span>{{ states('sensor.thermiq_mqtt_vp1_hgw_water_t') }}<span class="hpwidget-unit-span">&nbsp;C</span></div>
<div class="hpwidget-val" title="Supply-line Temperature" style="position:absolute;top:131px;left:138px;z-index:3;"><span class="hpwidget-name-span" id="hpwidget-T_FRAM"></span>{{ states('sensor.thermiq_mqtt_vp1_supplyline_t') }}<span class="hpwidget-unit-span">&nbsp;C</span></div>
<div class="hpwidget-val" title="Supply pump" style="position:absolute;top:257px;left:146px;z-index:3;{% if (states('sensor.thermiq_mqtt_vp1_opt_optimum_installed')=='off') %}display:none;{% endif %}"><span class="hpwidget-name-span" id="hpwidget-CIRK_SPEED"></span>{{ states('sensor.thermiq_mqtt_vp1_supply_pump_speed') }}<span class="hpwidget-unit-span">&nbsp;%</span></div>
<div class="hpwidget-val" title="Brine pump" style="position:absolute;top:156px;left:8px;z-index:3;{% if (states('sensor.thermiq_mqtt_vp1_opt_optimum_installed')=='off') %}display:none;{% endif %}"><span class="hpwidget-name-span" id="hpwidget-BRINE_SPEED"></span>{{ states('sensor.thermiq_mqtt_vp1_brine_pump_speed') }}<span class="hpwidget-unit-span">&nbsp;%</span></div>
<div class="hpwidget-val" title="Supply pump" style="position:absolute;top:257px;left:146px;z-index:3;{% if (states('binary_sensor.thermiq_mqtt_vp1_opt_optimum_installed')==false) %}display:none;{% endif %}"><span class="hpwidget-name-span" id="hpwidget-CIRK_SPEED"></span>{{ states('sensor.thermiq_mqtt_vp1_supply_pump_speed') }}<span class="hpwidget-unit-span">&nbsp;%</span></div>
<div class="hpwidget-val" title="Brine pump" style="position:absolute;top:156px;left:8px;z-index:3;{% if (states('binary_sensor.thermiq_mqtt_vp1_opt_optimum_installed')==false) %}display:none;{% endif %}"><span class="hpwidget-name-span" id="hpwidget-BRINE_SPEED"></span>{{ states('sensor.thermiq_mqtt_vp1_brine_pump_speed') }}<span class="hpwidget-unit-span">&nbsp;%</span></div>
<div class="hpwidget-val" title="Return line Temperature" style="position:absolute;top:200px;left:146px;z-index:3;"><span class="hpwidget-name-span" id="hpwidget-T_RETUR"></span>{{ states('sensor.thermiq_mqtt_vp1_returnline_t') }}<span class="hpwidget-unit-span">&nbsp;C</span></div>
<div class="hpwidget-val" title="Pressure pipe Temperature" style="position:absolute;top:125px;left:76px;z-index:3;"><span class="hpwidget-name-span" id="hpwidget-TRYCKR_T"></span>{{ states('sensor.thermiq_mqtt_vp1_pressurepipe_t') }}<span class="hpwidget-unit-span">&nbsp;C</span></div>
<ha-icon icon="mdi:flash" id="hpwidget-ELEFF" style="color:yellow;position:absolute;top:42px;left:82px;z-index:2;{% if ((states('sensor.thermiq_mqtt_vp1_boiler_3kw_on')=='off') and (states('sensor.thermiq_mqtt_vp1_boiler_6kw_on')=='off') ) %}display:none{% endif %}"></ha-icon>
<ha-icon icon="mdi:cog" id="hpwidget-KOMPR" style="position:absolute;top:155px;left:70px;--mdc-icon-size:45px;z-index:2;{% if (states('sensor.thermiq_mqtt_vp1_compressor_on')=='on') %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:fan" id="hpwidget-BRINESPIN" style="position:absolute;top:126px;left:11px;z-index:2;{% if (states('sensor.thermiq_mqtt_vp1_brine_pump_on')=='on') %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:fan" id="hpwidget-CIRKPSPIN" style="position:absolute;top:228px;left:147px;z-index:2;{% if (states('sensor.thermiq_mqtt_vp1_supply_pump_on')=='on') %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:alert-circle" id="hpwidget-ALERT" style="color:red;position:absolute;top:42px;left:82px;z-index:120;animation: blink 1s steps(5, start) infinite;{% if (states('sensor.thermiq_mqtt_vp1_communication_status')=='Ok') %}display:none{% endif %}"></ha-icon>
<ha-icon icon="mdi:flash" id="hpwidget-ELEFF" style="color:yellow;position:absolute;top:42px;left:82px;z-index:2;{% if ((states('binary_sensor.thermiq_mqtt_vp1_boiler_3kw_on')==false) and (states('binary_sensor.thermiq_mqtt_vp1_boiler_6kw_on')==false) ) %}display:none{% endif %}"></ha-icon>
<ha-icon icon="mdi:cog" id="hpwidget-KOMPR" style="position:absolute;top:155px;left:70px;--mdc-icon-size:45px;z-index:2;{% if (states('binary_sensor.thermiq_mqtt_vp1_compressor_on')==true) %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:fan" id="hpwidget-BRINESPIN" style="position:absolute;top:126px;left:11px;z-index:2;{% if (states('binary_sensor.thermiq_mqtt_vp1_brine_pump_on')==true) %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:fan" id="hpwidget-CIRKPSPIN" style="position:absolute;top:228px;left:147px;z-index:2;{% if (states('binary_sensor.thermiq_mqtt_vp1_supply_pump_on')==true) %}animation: rotating 2s linear infinite;{% endif %}"></ha-icon>
<ha-icon icon="mdi:alert-circle" id="hpwidget-ALERT" style="color:red;position:absolute;top:42px;left:82px;z-index:4;animation: blink 1s steps(5, start) infinite;{% if (states('sensor.thermiq_mqtt_vp1_communication_status')=='Ok') %}display:none{% endif %}"></ha-icon>
<ha-icon icon="mdi:stop" id="hpwidget-EVU" style="color:red;position:absolute;top:62px;left:82px;z-index:120;animation: blink 1s steps(5, start) infinite;{% if (states('sensor.thermiq_mqtt_vp1_heatpump_evu_block') | int ==0) %}display:none{% endif %}">EVU</ha-icon>
</div>
<div class="hpwidget-vald" title="Indoor Temperature" style="position:absolute;top:70px;left: 24px;z-index:2;><span class="hpwidget-name-span" id="hpwidget-INDR_T"></span>{{ states('sensor.thermiq_mqtt_vp1_indoor_t') }}<span class="hpwidget-unit-spand">&nbsp;C</span></div>
<div class="hpwidget-vald" title="Indoor Temperature" style="position:absolute;top:20px;left:24px;z-index:2;><span class="hpwidget-name-span" id="hpwidget-OUTDOOR_T"></span>{{ states('sensor.thermiq_mqtt_vp1_outdoor_t') }}<span class="hpwidget-unit-spand">&nbsp;C</span></div>
<ha-icon icon="mdi:home-roof"id="hpwidget-EVU" style="color:grey;position:absolute;top:26px;left:8px;z-index:4;--mdc-icon-size:65px;">Temp</ha-icon>
</div>
Expand Down
7 changes: 3 additions & 4 deletions custom_components/thermiq_mqtt/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from homeassistant.helpers.device_registry import DeviceEntryType

from homeassistant.const import (
TEMP_CELSIUS,
PERCENTAGE
)
from .const import (
Expand Down Expand Up @@ -89,7 +88,7 @@ def __init__(self, hass, heatpump, device_id, vp_reg, friendly_name, bitmask):

# set HA instance attributes directly (mostly don't use property)
# self._attr_unique_id
self.entity_id = f"sensor.{heatpump._domain}_{heatpump._id}_{device_id}"
self.entity_id = f"binary_sensor.{heatpump._domain}_{heatpump._id}_{device_id}"

_LOGGER.debug("entity_id:" + self.entity_id)
_LOGGER.debug("idx:" + device_id)
Expand Down Expand Up @@ -134,7 +133,7 @@ def should_poll(self):
@property
def state(self):
"""Return the state of the sensor."""
return STATE_ON if self._state else STATE_OFF
return (self._state)

@property
def vp_reg(self):
Expand All @@ -143,7 +142,7 @@ def vp_reg(self):

@property
def is_on(self):
return self._state is True
return STATE_ON if (self._state) else STATE_OFF

@property
def sorter(self):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/thermiq_mqtt/input_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
CONF_MODE,
CONF_NAME,
CONF_UNIT_OF_MEASUREMENT,
TEMP_CELSIUS,
UnitOfTemperature.CELSIUS,
)
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import EntityPlatform
Expand Down Expand Up @@ -120,7 +120,7 @@ def create_input_number_entity(heatpump, name) -> CustomInputNumber:
]
):
icon = "mdi:temperature-celsius"
unit = TEMP_CELSIUS
unit = UnitOfTemperature.CELSIUS
else:
unit = reg_id[name][2]
icon = "mdi:gauge"
Expand Down
6 changes: 3 additions & 3 deletions custom_components/thermiq_mqtt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.helpers.entity import Entity, async_generate_entity_id

from homeassistant.const import (
TEMP_CELSIUS,
UnitOfTemperature.CELSIUS,
PERCENTAGE
)

Expand Down Expand Up @@ -126,7 +126,7 @@ def __init__(
]
):
self._icon = "mdi:temperature-celsius"
self._unit = TEMP_CELSIUS
self._unit = UnitOfTemperature.CELSIUS
elif vp_type in [
"sensor_boolean",
]:
Expand All @@ -142,7 +142,7 @@ def __init__(
self._idx = device_id
self._vp_reg = vp_reg

# self.device_class [temperature, voltaage,
# self.device_class [temperature, voltage,
#self.state_class= measurement

# Listen for the ThermIQ rec event indicating new data
Expand Down

0 comments on commit 98459a5

Please sign in to comment.