Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mystrom support for temperature of Hardware v2 #36580

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/mystrom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "mystrom",
"name": "myStrom",
"documentation": "https://www.home-assistant.io/integrations/mystrom",
"requirements": ["python-mystrom==1.1.2"],
"requirements": ["python-mystrom==1.1.3"],
"dependencies": ["http"],
"codeowners": ["@fabaff"]
}
11 changes: 10 additions & 1 deletion homeassistant/components/mystrom/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import voluptuous as vol

from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
from homeassistant.const import CONF_HOST, CONF_NAME
from homeassistant.const import ATTR_TEMPERATURE, CONF_HOST, CONF_NAME
from homeassistant.exceptions import PlatformNotReady
import homeassistant.helpers.config_validation as cv

Expand Down Expand Up @@ -46,6 +46,7 @@ def __init__(self, plug, name):
self.plug = plug
self._available = True
self.relay = None
self._attrs = {}

@property
def name(self):
Expand All @@ -72,6 +73,14 @@ def available(self):
"""Could the device be accessed during the last update call."""
return self._available

@property
def device_state_attributes(self):
"""Return the device state attributes."""
if self.plug.temperature is not None:
self._attrs[ATTR_TEMPERATURE] = self.plug.temperature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should publish this as a sensor, not include it as an attribute of the switch.


return self._attrs

async def async_turn_on(self, **kwargs):
"""Turn the switch on."""
try:
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ python-miio==0.5.0.1
python-mpd2==1.0.0

# homeassistant.components.mystrom
python-mystrom==1.1.2
python-mystrom==1.1.3

# homeassistant.components.nest
python-nest==4.1.0
Expand Down