Skip to content
Snippets Groups Projects
Commit 1b1e761f authored by jkerdreu's avatar jkerdreu
Browse files

- Switch to new units

- Fix the space issue on ha_name

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@3054 b32b6428-25c9-4566-ad07-03861ab6144f
parent 6cc6bcb4
No related branches found
No related tags found
No related merge requests found
...@@ -111,7 +111,7 @@ class XAALEntity(Entity): ...@@ -111,7 +111,7 @@ class XAALEntity(Entity):
db_name = self._dev.db.get('ha_name') db_name = self._dev.db.get('ha_name')
dev_name = self._dev.db.get('ha_dev_name') dev_name = self._dev.db.get('ha_dev_name')
if dev_name and db_name: if dev_name and db_name:
db_name = db_name.removeprefix(dev_name) db_name = db_name.removeprefix(f"{dev_name} ")
force_name = getattr(self, '_force_name', None) force_name = getattr(self, '_force_name', None)
name = db_name or force_name or self.device_class or self.short_type() name = db_name or force_name or self.device_class or self.short_type()
...@@ -396,7 +396,7 @@ class Bridge(object): ...@@ -396,7 +396,7 @@ class Bridge(object):
entity = self.get_entity_by_id(entity_id) entity = self.get_entity_by_id(entity_id)
if entity: if entity:
name = entity.registry_entry.name name = entity.registry_entry.name
if 'name' not in event.data.get('changes',{}).keys(): if 'name' not in event.data.get('changes', {}).keys():
return return
kv = {'ha_name': name} kv = {'ha_name': name}
body = {'device': entity.address, 'map': kv} body = {'device': entity.address, 'map': kv}
......
...@@ -58,7 +58,7 @@ class Hygrometer(XAALSensorEntity): ...@@ -58,7 +58,7 @@ class Hygrometer(XAALSensorEntity):
class Barometer(XAALSensorEntity): class Barometer(XAALSensorEntity):
_attr_device_class = SensorDeviceClass.PRESSURE _attr_device_class = SensorDeviceClass.PRESSURE
_attr_native_unit_of_measurement = const.PRESSURE_HPA _attr_native_unit_of_measurement = const.UnitOfPressure.HPA
_xaal_attribute = 'pressure' _xaal_attribute = 'pressure'
...@@ -71,7 +71,7 @@ class Battery(XAALSensorEntity): ...@@ -71,7 +71,7 @@ class Battery(XAALSensorEntity):
class PowerMeter(XAALSensorEntity): class PowerMeter(XAALSensorEntity):
_attr_device_class = SensorDeviceClass.POWER _attr_device_class = SensorDeviceClass.POWER
_attr_native_unit_of_measurement = const.POWER_WATT _attr_native_unit_of_measurement = const.UnitOfPower.WATT
_xaal_attribute = 'power' _xaal_attribute = 'power'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment