mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Add override switch for juicenet (#28049)
* Add override switch for juicenet * Update generated files * Update indentation * Fix indentation * Remove unnecessary else statement * Update homeassistant/components/juicenet/switch.py Co-Authored-By: Fabian Affolter <mail@fabian-affolter.ch> * Update homeassistant/components/juicenet/switch.py Co-Authored-By: Fabian Affolter <mail@fabian-affolter.ch> * Remove state property * Change string formatting * Bump juicenet package version again
This commit is contained in:
parent
11efb2c2eb
commit
a43095b2b5
@ -156,6 +156,7 @@ homeassistant/components/iqvia/* @bachya
|
|||||||
homeassistant/components/irish_rail_transport/* @ttroy50
|
homeassistant/components/irish_rail_transport/* @ttroy50
|
||||||
homeassistant/components/izone/* @Swamp-Ig
|
homeassistant/components/izone/* @Swamp-Ig
|
||||||
homeassistant/components/jewish_calendar/* @tsvi
|
homeassistant/components/jewish_calendar/* @tsvi
|
||||||
|
homeassistant/components/juicenet/* @jesserockz
|
||||||
homeassistant/components/kaiterra/* @Michsior14
|
homeassistant/components/kaiterra/* @Michsior14
|
||||||
homeassistant/components/keba/* @dannerph
|
homeassistant/components/keba/* @dannerph
|
||||||
homeassistant/components/keenetic_ndms2/* @foxel
|
homeassistant/components/keenetic_ndms2/* @foxel
|
||||||
|
@ -18,6 +18,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
JUICENET_COMPONENTS = ["sensor", "switch"]
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Set up the Juicenet component."""
|
"""Set up the Juicenet component."""
|
||||||
@ -26,7 +28,9 @@ def setup(hass, config):
|
|||||||
access_token = config[DOMAIN].get(CONF_ACCESS_TOKEN)
|
access_token = config[DOMAIN].get(CONF_ACCESS_TOKEN)
|
||||||
hass.data[DOMAIN]["api"] = pyjuicenet.Api(access_token)
|
hass.data[DOMAIN]["api"] = pyjuicenet.Api(access_token)
|
||||||
|
|
||||||
discovery.load_platform(hass, "sensor", DOMAIN, {}, config)
|
for component in JUICENET_COMPONENTS:
|
||||||
|
discovery.load_platform(hass, component, DOMAIN, {}, config)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
"name": "Juicenet",
|
"name": "Juicenet",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/juicenet",
|
"documentation": "https://www.home-assistant.io/integrations/juicenet",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"python-juicenet==0.0.5"
|
"python-juicenet==0.1.5"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": []
|
"codeowners": [
|
||||||
|
"@jesserockz"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
45
homeassistant/components/juicenet/switch.py
Normal file
45
homeassistant/components/juicenet/switch.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
"""Support for monitoring juicenet/juicepoint/juicebox based EVSE switches."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
|
from . import DOMAIN, JuicenetDevice
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
|
"""Set up the Juicenet switch."""
|
||||||
|
api = hass.data[DOMAIN]["api"]
|
||||||
|
|
||||||
|
devs = []
|
||||||
|
for device in api.get_devices():
|
||||||
|
devs.append(JuicenetChargeNowSwitch(device, hass))
|
||||||
|
|
||||||
|
add_entities(devs)
|
||||||
|
|
||||||
|
|
||||||
|
class JuicenetChargeNowSwitch(JuicenetDevice, SwitchDevice):
|
||||||
|
"""Implementation of a Juicenet switch."""
|
||||||
|
|
||||||
|
def __init__(self, device, hass):
|
||||||
|
"""Initialise the switch."""
|
||||||
|
super().__init__(device, "charge_now", hass)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the device."""
|
||||||
|
return f"{self.device.name()} Charge Now"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
"""Return true if switch is on."""
|
||||||
|
return self.device.getOverrideTime() != 0
|
||||||
|
|
||||||
|
def turn_on(self, **kwargs):
|
||||||
|
"""Charge now."""
|
||||||
|
self.device.setOverride(True)
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs):
|
||||||
|
"""Don't charge now."""
|
||||||
|
self.device.setOverride(False)
|
@ -1537,7 +1537,7 @@ python-izone==1.1.1
|
|||||||
python-join-api==0.0.4
|
python-join-api==0.0.4
|
||||||
|
|
||||||
# homeassistant.components.juicenet
|
# homeassistant.components.juicenet
|
||||||
python-juicenet==0.0.5
|
python-juicenet==0.1.5
|
||||||
|
|
||||||
# homeassistant.components.lirc
|
# homeassistant.components.lirc
|
||||||
# python-lirc==1.2.3
|
# python-lirc==1.2.3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user