mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Added epson workforce component (#23144)
* Added epson workforce component * Added __init__ file
This commit is contained in:
parent
dcb4eb39fa
commit
5b33d952aa
@ -162,6 +162,7 @@ omit =
|
|||||||
homeassistant/components/envisalink/*
|
homeassistant/components/envisalink/*
|
||||||
homeassistant/components/ephember/climate.py
|
homeassistant/components/ephember/climate.py
|
||||||
homeassistant/components/epson/media_player.py
|
homeassistant/components/epson/media_player.py
|
||||||
|
homeassistant/components/epsonworkforce/sensor.py
|
||||||
homeassistant/components/eq3btsmart/climate.py
|
homeassistant/components/eq3btsmart/climate.py
|
||||||
homeassistant/components/esphome/__init__.py
|
homeassistant/components/esphome/__init__.py
|
||||||
homeassistant/components/esphome/binary_sensor.py
|
homeassistant/components/esphome/binary_sensor.py
|
||||||
|
@ -67,6 +67,7 @@ homeassistant/components/eight_sleep/* @mezz64
|
|||||||
homeassistant/components/emby/* @mezz64
|
homeassistant/components/emby/* @mezz64
|
||||||
homeassistant/components/enigma2/* @fbradyirl
|
homeassistant/components/enigma2/* @fbradyirl
|
||||||
homeassistant/components/ephember/* @ttroy50
|
homeassistant/components/ephember/* @ttroy50
|
||||||
|
homeassistant/components/epsonworkforce/* @ThaStealth
|
||||||
homeassistant/components/eq3btsmart/* @rytilahti
|
homeassistant/components/eq3btsmart/* @rytilahti
|
||||||
homeassistant/components/esphome/* @OttoWinter
|
homeassistant/components/esphome/* @OttoWinter
|
||||||
homeassistant/components/file/* @fabaff
|
homeassistant/components/file/* @fabaff
|
||||||
|
1
homeassistant/components/epsonworkforce/__init__.py
Normal file
1
homeassistant/components/epsonworkforce/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""The epsonworkforce component."""
|
9
homeassistant/components/epsonworkforce/manifest.json
Normal file
9
homeassistant/components/epsonworkforce/manifest.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"domain": "epsonworkforce",
|
||||||
|
"name": "Epson Workforce",
|
||||||
|
"documentation": "https://www.home-assistant.io/components/epsonworkforce",
|
||||||
|
"dependencies": [],
|
||||||
|
"codeowners": ["@ThaStealth"],
|
||||||
|
"requirements": ["epsonprinter==0.0.8"]
|
||||||
|
}
|
||||||
|
|
85
homeassistant/components/epsonworkforce/sensor.py
Normal file
85
homeassistant/components/epsonworkforce/sensor.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
"""Support for Epson Workforce Printer."""
|
||||||
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
|
from homeassistant.const import CONF_HOST, CONF_MONITORED_CONDITIONS
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
|
REQUIREMENTS = ['epsonprinter==0.0.8']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
MONITORED_CONDITIONS = {
|
||||||
|
'black': ['Inklevel Black', '%', 'mdi:water'],
|
||||||
|
'magenta': ['Inklevel Magenta', '%', 'mdi:water'],
|
||||||
|
'cyan': ['Inklevel Cyan', '%', 'mdi:water'],
|
||||||
|
'yellow': ['Inklevel Yellow', '%', 'mdi:water'],
|
||||||
|
'clean': ['Inklevel Cleaning', '%', 'mdi:water'],
|
||||||
|
}
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_HOST): cv.string,
|
||||||
|
vol.Required(CONF_MONITORED_CONDITIONS):
|
||||||
|
vol.All(cv.ensure_list, [vol.In(MONITORED_CONDITIONS)]),
|
||||||
|
})
|
||||||
|
SCAN_INTERVAL = timedelta(minutes=60)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
|
"""Set up the cartridge sensor."""
|
||||||
|
host = config.get(CONF_HOST)
|
||||||
|
|
||||||
|
from epsonprinter_pkg.epsonprinterapi import EpsonPrinterAPI
|
||||||
|
api = EpsonPrinterAPI(host)
|
||||||
|
if not api.available:
|
||||||
|
raise PlatformNotReady()
|
||||||
|
|
||||||
|
sensors = [EpsonPrinterCartridge(api, condition)
|
||||||
|
for condition in config[CONF_MONITORED_CONDITIONS]]
|
||||||
|
|
||||||
|
add_devices(sensors, True)
|
||||||
|
|
||||||
|
|
||||||
|
class EpsonPrinterCartridge(Entity):
|
||||||
|
"""Representation of a cartridge sensor."""
|
||||||
|
|
||||||
|
def __init__(self, api, cartridgeidx):
|
||||||
|
"""Initialize a cartridge sensor."""
|
||||||
|
self._api = api
|
||||||
|
|
||||||
|
self._id = cartridgeidx
|
||||||
|
self._name = MONITORED_CONDITIONS[self._id][0]
|
||||||
|
self._unit = MONITORED_CONDITIONS[self._id][1]
|
||||||
|
self._icon = MONITORED_CONDITIONS[self._id][2]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the name of the sensor."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
"""Icon to use in the frontend, if any."""
|
||||||
|
return self._icon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unit_of_measurement(self):
|
||||||
|
"""Return the unit the value is expressed in."""
|
||||||
|
return self._unit
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
"""Return the state of the device."""
|
||||||
|
return self._api.getSensorValue(self._id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self):
|
||||||
|
"""Could the device be accessed during the last update call."""
|
||||||
|
return self._api.available
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Get the latest data from the Epson printer."""
|
||||||
|
self._api.update()
|
@ -397,6 +397,9 @@ ephem==3.7.6.0
|
|||||||
# homeassistant.components.epson
|
# homeassistant.components.epson
|
||||||
epson-projector==0.1.3
|
epson-projector==0.1.3
|
||||||
|
|
||||||
|
# homeassistant.components.epsonworkforce
|
||||||
|
epsonprinter==0.0.8
|
||||||
|
|
||||||
# homeassistant.components.netgear_lte
|
# homeassistant.components.netgear_lte
|
||||||
eternalegypt==0.0.7
|
eternalegypt==0.0.7
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user