Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _setup_sensor(self, temp, unit=TEMP_CELSIUS):
"""Setup the test sensor."""
self.hass.states.set(ENT_SENSOR, temp, {
ATTR_UNIT_OF_MEASUREMENT: unit
})
def temperature_unit(self):
"""Return the unit of measurement which this thermostat uses."""
return TEMP_CELSIUS
def temperature_unit(self):
"""Return the unit of measurement which this device uses."""
return TEMP_CELSIUS
"Printing": ["printer", "state", "printing", None],
"Printing Error": ["printer", "state", "error", None],
}
BINARY_SENSOR_SCHEMA = vol.Schema(
{
vol.Optional(
CONF_MONITORED_CONDITIONS, default=list(BINARY_SENSOR_TYPES)
): vol.All(cv.ensure_list, [vol.In(BINARY_SENSOR_TYPES)]),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}
)
SENSOR_TYPES = {
# API Endpoint, Group, Key, unit, icon
"Temperatures": ["printer", "temperature", "*", TEMP_CELSIUS],
"Current State": ["printer", "state", "text", None, "mdi:printer-3d"],
"Job Percentage": ["job", "progress", "completion", "%", "mdi:file-percent"],
"Time Remaining": ["job", "progress", "printTimeLeft", "seconds", "mdi:clock-end"],
"Time Elapsed": ["job", "progress", "printTime", "seconds", "mdi:clock-start"],
}
SENSOR_SCHEMA = vol.Schema(
{
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(SENSOR_TYPES)): vol.All(
cv.ensure_list, [vol.In(SENSOR_TYPES)]
),
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
}
)
CONFIG_SCHEMA = vol.Schema(
def unit_of_measurement(self):
"""Return the unit of measurement."""
if self.device_type == "Hive_OutsideTemperature":
return TEMP_CELSIUS
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the available Danfoss Air sensors etc."""
from pydanfossair.commands import ReadCommand
data = hass.data[DANFOSS_AIR_DOMAIN]
sensors = [
[
"Danfoss Air Exhaust Temperature",
TEMP_CELSIUS,
ReadCommand.exhaustTemperature,
DEVICE_CLASS_TEMPERATURE,
],
[
"Danfoss Air Outdoor Temperature",
TEMP_CELSIUS,
ReadCommand.outdoorTemperature,
DEVICE_CLASS_TEMPERATURE,
],
[
"Danfoss Air Supply Temperature",
TEMP_CELSIUS,
ReadCommand.supplyTemperature,
DEVICE_CLASS_TEMPERATURE,
],
[
"Danfoss Air Extract Temperature",
TEMP_CELSIUS,
ReadCommand.extractTemperature,
DEVICE_CLASS_TEMPERATURE,
],
["Danfoss Air Remaining Filter", "%", ReadCommand.filterPercent, None],
SUPPORTED_PUBLIC_SENSOR_TYPES = [
"temperature",
"pressure",
"humidity",
"rain",
"windstrength",
"guststrength",
"sum_rain_1",
"sum_rain_24",
]
SENSOR_TYPES = {
"temperature": [
"Temperature",
TEMP_CELSIUS,
"mdi:thermometer",
DEVICE_CLASS_TEMPERATURE,
],
"co2": ["CO2", "ppm", "mdi:periodic-table-co2", None],
"pressure": ["Pressure", "mbar", "mdi:gauge", None],
"noise": ["Noise", "dB", "mdi:volume-high", None],
"humidity": ["Humidity", "%", "mdi:water-percent", DEVICE_CLASS_HUMIDITY],
"rain": ["Rain", "mm", "mdi:weather-rainy", None],
"sum_rain_1": ["sum_rain_1", "mm", "mdi:weather-rainy", None],
"sum_rain_24": ["sum_rain_24", "mm", "mdi:weather-rainy", None],
"battery_vp": ["Battery", "", "mdi:battery", None],
"battery_lvl": ["Battery_lvl", "", "mdi:battery", None],
"battery_percent": ["battery_percent", "%", None, DEVICE_CLASS_BATTERY],
"min_temp": ["Min Temp.", TEMP_CELSIUS, "mdi:thermometer", None],
"max_temp": ["Max Temp.", TEMP_CELSIUS, "mdi:thermometer", None],
"windangle": ["Angle", "", "mdi:compass", None],
def temperature(self):
"""Return the current temperature."""
temp_c = None
if self.observation:
temp_c = self.observation.get("temperature")
if temp_c:
return convert_temperature(temp_c, TEMP_CELSIUS, TEMP_FAHRENHEIT)
return None
from homeassistant.const import (
STATE_UNKNOWN, STATE_OFF, STATE_ON, TEMP_CELSIUS, TEMP_FAHRENHEIT,
)
CLIMATE_IP_PROPERTIES = []
CLIMATE_IP_STATUS_GETTER = []
PROPERTY_TYPE_MODE = 'modes'
PROPERTY_TYPE_SWITCH = 'switch'
PROPERTY_TYPE_NUMBER = 'number'
PROPERTY_TYPE_TEMP = 'temperature'
STATUS_GETTER_JSON = 'json_status'
UNIT_MAP = {
'C': TEMP_CELSIUS,
'c': TEMP_CELSIUS,
'Celsius': TEMP_CELSIUS,
'F': TEMP_FAHRENHEIT,
'f': TEMP_FAHRENHEIT,
'Fahrenheit': TEMP_FAHRENHEIT,
TEMP_CELSIUS: TEMP_CELSIUS,
TEMP_FAHRENHEIT: TEMP_FAHRENHEIT,
}
test_json = {'Devices':[{'Alarms':[{'alarmType':'Device','code':'FilterAlarm','id':'0','triggeredTime':'2019-02-25T08:46:01'}],'ConfigurationLink':{'href':'/devices/0/configuration'},'Diagnosis':{'diagnosisStart':'Ready'},'EnergyConsumption':{'saveLocation':'/files/usage.db'},'InformationLink':{'href':'/devices/0/information'},'Mode':{'modes':['Auto'],'options':['Comode_Off','Sleep_0','Autoclean_Off','Spi_Off','FilterCleanAlarm_0','OutdoorTemp_63','CoolCapa_35','WarmCapa_40','UsagesDB_254','FilterTime_10000','OptionCode_54458','UpdateAllow_0','FilterAlarmTime_500','Function_15','Volume_100'],'supportedModes':['Cool','Dry','Wind','Auto']},'Operation':{'power':'Off'},'Temperatures':[{'current':22.0,'desired':25.0,'id':'0','maximum':30,'minimum':16,'unit':'Celsius'}],'Wind':{'direction':'Fix','maxSpeedLevel':4,'speedLevel':0},'connected':True,'description':'TP6X_RAC_16K','id':'0','name':'RAC','resources':['Alarms','Configuration','Diagnosis','EnergyConsumption','Information','Mode','Operation','Temperatures','Wind'],'type':'Air_Conditioner','uuid':'C0972729-EB73-0000-0000-000000000000'}]}
def register_property(dev_prop):
"""Decorate a function to register a propery."""
CLIMATE_IP_PROPERTIES.append(dev_prop)
return dev_prop
def register_status_getter(getter):
def update(self):
"""Update the state."""
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
self.current_value = self.vera_device.temperature
vera_temp_units = self.vera_device.vera_controller.temperature_units
if vera_temp_units == "F":
self._temperature_units = TEMP_FAHRENHEIT
else:
self._temperature_units = TEMP_CELSIUS
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_UV_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
self.current_value = self.vera_device.humidity
elif self.vera_device.category == veraApi.CATEGORY_SCENE_CONTROLLER:
value = self.vera_device.get_last_scene_id(True)
time = self.vera_device.get_last_scene_time(True)
if time == self.last_changed_time:
self.current_value = None
else:
self.current_value = value
self.last_changed_time = time
elif self.vera_device.category == veraApi.CATEGORY_POWER_METER: