Skip to content

Commit

Permalink
API updates (#17)
Browse files Browse the repository at this point in the history
* Use extra_state_attributes instead of device_state_attributes.

* Update changelog.

* Use attribute notation for discovery_info.
  • Loading branch information
ppetru authored Dec 21, 2021
1 parent c6461a7 commit eae6ca2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Forgot to update the version in manifest.json all this time
- Use extra_state_attributes instead of device_state_attributes
- Use atribute notation instead of key notation for discovery_info

## [0.5.1] - 2021-06-18

Expand Down
4 changes: 2 additions & 2 deletions custom_components/weatherlink/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ async def async_step_user(self, info):
async def async_step_zeroconf(
self, discovery_info: Dict[str, Any]
) -> Dict[str, Any]:
host: str = discovery_info["host"]
port: int = discovery_info["port"]
host: str = discovery_info.host
port: int = discovery_info.port
try:
self.discovery_data = await self.discover(f"http://{host}:{port}")
return await self.async_step_zeroconf_confirm()
Expand Down
4 changes: 2 additions & 2 deletions custom_components/weatherlink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def state(self):
return self.units.pressure.convert(self._lss_bar_condition.bar_sea_level)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
condition = self._lss_bar_condition
u = self.units.pressure
return {
Expand All @@ -54,7 +54,7 @@ def state(self):
return self.units.temperature.convert(self._lss_temp_hum_condition.temp_in)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
condition = self._lss_temp_hum_condition
u = self.units.temperature
return {
Expand Down
8 changes: 4 additions & 4 deletions custom_components/weatherlink/sensor_air_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def state(self):
return "connected"

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._aq_condition
return {
"last_report_time": c.last_report_time,
Expand All @@ -79,7 +79,7 @@ def state(self):
return self.units.temperature.convert(self._aq_condition.temp)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._aq_condition
u = self.units.temperature
return {
Expand Down Expand Up @@ -130,7 +130,7 @@ def state(self):
return self.units.pm.convert(self._aq_condition.pm_2p5_nowcast)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._aq_condition
u = self.units.pm
return {
Expand All @@ -156,7 +156,7 @@ def state(self):
return self.units.pm.convert(self._aq_condition.pm_10_nowcast)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._aq_condition
u = self.units.pm
return {
Expand Down
18 changes: 9 additions & 9 deletions custom_components/weatherlink/sensor_iss.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def state(self):
return rx_state.name

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
return {
"txid": c.txid,
Expand All @@ -75,7 +75,7 @@ def state(self):
return self.units.temperature.convert_optional(self._iss_condition.temp)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.temperature
return {
Expand Down Expand Up @@ -127,7 +127,7 @@ def state(self):
)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.wind_speed
return {
Expand Down Expand Up @@ -169,7 +169,7 @@ def state(self):
)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.wind_speed
return {
Expand All @@ -192,7 +192,7 @@ def state(self):
return self._iss_condition.wind_dir_scalar_avg_last_2_min

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
return {
"high": c.wind_dir_at_hi_speed_last_2_min,
Expand Down Expand Up @@ -251,7 +251,7 @@ def state(self):
return self.bearing_to_dir(self._iss_condition.wind_dir_scalar_avg_last_2_min)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
return {
"high": self.bearing_to_dir(c.wind_dir_at_hi_speed_last_2_min),
Expand Down Expand Up @@ -311,7 +311,7 @@ def state(self):
return self.units.rain_rate.convert(self._iss_condition.rain_rate_last)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.rain_rate
return {
Expand All @@ -335,7 +335,7 @@ def state(self):
return self.units.rainfall.convert(self._iss_condition.rainfall_daily)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.rainfall
return {
Expand All @@ -362,7 +362,7 @@ def state(self):
return self.units.rainfall.convert_optional(self._iss_condition.rain_storm)

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._iss_condition
u = self.units.rainfall
return {
Expand Down
4 changes: 2 additions & 2 deletions custom_components/weatherlink/sensor_moisture.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def state(self):
return rx_state.name

@property
def device_state_attributes(self):
def extra_state_attributes(self):
c = self._moisture_condition
return {
"txid": c.txid,
Expand Down Expand Up @@ -168,7 +168,7 @@ def state(self):
return None

@property
def device_state_attributes(self):
def extra_state_attributes(self):
return {
"raw": round_optional(self._wet_leaf(self._moisture_condition), 1),
}
Expand Down

0 comments on commit eae6ca2

Please sign in to comment.