Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ homeassistant/components/iqvia/* @bachya
homeassistant/components/irish_rail_transport/* @ttroy50
homeassistant/components/izone/* @Swamp-Ig
homeassistant/components/jewish_calendar/* @tsvi
homeassistant/components/juicenet/* @jesserockz
homeassistant/components/kaiterra/* @Michsior14
homeassistant/components/keba/* @dannerph
homeassistant/components/keenetic_ndms2/* @foxel
Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/juicenet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
extra=vol.ALLOW_EXTRA,
)

JUICENET_COMPONENTS = ["sensor", "switch"]


def setup(hass, config):
"""Set up the Juicenet component."""
Expand All @@ -27,7 +29,9 @@ def setup(hass, config):
access_token = config[DOMAIN].get(CONF_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


Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/juicenet/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"name": "Juicenet",
"documentation": "https://www.home-assistant.io/integrations/juicenet",
"requirements": [
"python-juicenet==0.0.5"
"python-juicenet==0.1.5"
],
"dependencies": [],
"codeowners": []
"codeowners": [
"@jesserockz"
]
}
45 changes: 45 additions & 0 deletions homeassistant/components/juicenet/switch.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ python-izone==1.1.1
python-join-api==0.0.4

# homeassistant.components.juicenet
python-juicenet==0.0.5
python-juicenet==0.1.5

# homeassistant.components.lirc
# python-lirc==1.2.3
Expand Down