Skip to content

Commit

Permalink
📈 added unit_of_measurement (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyibo committed Jan 15, 2023
1 parent f831146 commit 4489593
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions custom_components/petkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,23 +490,23 @@ def hass_sensor(self):
'state_attrs': self.feed_state_attrs,
},
'feed_amount': {
'unit': 'g',
'unit': MASS_GRAMS,
'icon': 'mdi:weight-gram',
'state_attrs': self.feed_state_attrs,
},
}
if self.device_type == 'd3':
dat.update({
'eat_amount': {
'unit': 'g',
'unit': MASS_GRAMS,
'icon': 'mdi:weight-gram',
},
'eat_times': {
'unit': 'times',
'icon': 'mdi:counter',
},
'bowl_weight': {
'unit': 'g',
'unit': MASS_GRAMS,
'icon': 'mdi:weight-gram',
},
})
Expand Down Expand Up @@ -641,17 +641,21 @@ def hass_sensor(self):
'sand_percent': {
'icon': 'mdi:percent-outline',
'state_attrs': self.sand_attrs,
'unit': PERCENTAGE,
},
'liquid': {
'icon': 'mdi:water-percent',
'state_attrs': self.liquid_attrs,
'unit': PERCENTAGE,
},
'pet_weight': {
'icon': 'mdi:weight',
'state_attrs': self.pet_weight_attrs,
'unit': MASS_GRAMS,
},
'in_times': {
'icon': 'mdi:location-enter',
'unit': 'times',
},
'last_record': {
'icon': 'mdi:history',
Expand Down Expand Up @@ -918,6 +922,10 @@ def update(self):
def state(self):
return self._attr_state

@property
def unit_of_measurement(self):
return self._attr_unit_of_measurement

async def async_request_api(self, api, params=None, method='GET', **kwargs):
throw = kwargs.pop('throw', None)
rdt = await self.account.request(api, params, method, **kwargs)
Expand Down

0 comments on commit 4489593

Please sign in to comment.