Package nl.tue.id.oocsi.client.data
Class OOCSIDevice
java.lang.Object
nl.tue.id.oocsi.client.data.OOCSIDevice
public class OOCSIDevice
extends java.lang.Object
OOCSIDevice allows to configure one or more devices for an OOCSI client that can be recognized by HomeAssistant (and
the OOCSI server) and will then be displayed or treated otherwise in a semantically correct way.
- Author:
- matsfunk
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OOCSIDevice.BinarySensorType
from: https://developers.home-assistant.io/docs/core/entity/binary-sensor/#available-device-classesstatic class
OOCSIDevice.LedType
from: ? Tbd.static class
OOCSIDevice.LightSpectrum
from: ? Tbd.static class
OOCSIDevice.SensorType
from: https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classesstatic class
OOCSIDevice.SwitchType
from: https://developers.home-assistant.io/docs/core/entity/switch/#available-device-classes -
Constructor Summary
Constructors Constructor Description OOCSIDevice(OOCSIClient client, java.lang.String deviceName)
create a new OOCSI device -
Method Summary
Modifier and Type Method Description OOCSIDevice
addBinarySensor(java.lang.String name, java.lang.String channel, java.lang.String sensorType, boolean sensorDefault, java.lang.String icon)
add a binary sensor component to this deviceOOCSIDevice
addBinarySensor(java.lang.String name, java.lang.String channel, OOCSIDevice.BinarySensorType sensorType, boolean sensorDefault, java.lang.String icon)
add a binary sensor component to this deviceOOCSIDevice
addLight(java.lang.String name, java.lang.String channel, java.lang.String lightType, java.lang.String spectrum, int min, int max, boolean lightDefault, int defaultBrightness, java.lang.String icon)
add a sensor component to this deviceOOCSIDevice
addLight(java.lang.String name, java.lang.String channel, OOCSIDevice.LedType lightType, OOCSIDevice.LightSpectrum spectrum, int min, int max, boolean lightDefault, int defaultBrightness, java.lang.String icon)
add a sensor component to this deviceOOCSIDevice
addLocation(java.lang.String name, float lat, float lng)
add a device locationOOCSIDevice
addNumber(java.lang.String name, java.lang.String channel, float min, float max, float numberDefault, java.lang.String icon)
add a number component to this deviceOOCSIDevice
addNumber(java.lang.String name, java.lang.String channel, float min, float max, java.lang.String numberUnit, float numberDefault, java.lang.String icon)
add a number component to this deviceOOCSIDevice
addProperty(java.lang.String name, java.lang.String value)
add a device propertyOOCSIDevice
addSensor(java.lang.String name, java.lang.String channel, java.lang.String sensorType, java.lang.String sensorUnit, float sensorDefault, java.lang.String icon)
add a sensor component to this deviceOOCSIDevice
addSensor(java.lang.String name, java.lang.String channel, OOCSIDevice.SensorType sensorType, java.lang.String sensorUnit, float sensorDefault, java.lang.String icon)
add a sensor component to this deviceOOCSIDevice
addSwitch(java.lang.String name, java.lang.String channel, java.lang.String switchType, boolean switchDefault, java.lang.String icon)
add a switch component to this deviceOOCSIDevice
addSwitch(java.lang.String name, java.lang.String channel, OOCSIDevice.SwitchType switchType, boolean switchDefault, java.lang.String icon)
add a switch component to this deviceboolean
getState(boolean defaultValue)
retrieve the currently set state for the only component -- or default valueboolean
getStateOfComponent(java.lang.String componentName, boolean defaultValue)
retrieve the currently set state for the given component -- or default valuefloat
getValue(float defaultValue)
retrieve the currently set value for the only component -- or default valuefloat
getValue(java.lang.String key, float defaultValue)
retrieve the currently set value for a given key for the only component -- or default valuefloat
getValueOfComponent(java.lang.String componentName, float defaultValue)
retrieve the currently set default value for the given component -- or default valuefloat
getValueOfComponent(java.lang.String componentName, java.lang.String key, float defaultValue)
retrieve the currently set value for the given component and key -- or default valuevoid
sayHi()
alternative call for submit()void
setState(boolean state)
set the default value for the only componentvoid
setValue(java.lang.Number value)
set the default value for the only componentvoid
setValue(java.lang.String value)
set the default value for the only componentvoid
setValue(java.lang.String key, java.lang.Number value)
set the value for a given key for the only componentvoid
setValue(java.lang.String key, java.lang.String value)
set the value for a given key for the only componentvoid
setValueForComponent(java.lang.String componentName, java.lang.Number value)
set the default value for the given componentvoid
setValueForComponent(java.lang.String componentName, java.lang.String value)
set the default value for the given componentvoid
setValueForComponent(java.lang.String componentName, java.lang.String key, boolean value)
set a value for the given componentvoid
setValueForComponent(java.lang.String componentName, java.lang.String key, java.lang.Number value)
set a value for the given componentvoid
setValueForComponent(java.lang.String componentName, java.lang.String key, java.lang.String value)
set a value for the given componentvoid
submit()
submit the heyOOCSI! message to the serverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
OOCSIDevice
create a new OOCSI device- Parameters:
client
-deviceName
-
-
-
Method Details
-
addProperty
add a device property- Parameters:
name
-value
-- Returns:
-
addLocation
add a device location- Parameters:
name
-lat
-lng
-- Returns:
-
addNumber
public OOCSIDevice addNumber(java.lang.String name, java.lang.String channel, float min, float max, float numberDefault, java.lang.String icon)add a number component to this device- Parameters:
name
-channel
-min
-max
-numberDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addNumber
public OOCSIDevice addNumber(java.lang.String name, java.lang.String channel, float min, float max, java.lang.String numberUnit, float numberDefault, java.lang.String icon)add a number component to this device- Parameters:
name
-channel
-min
-max
-numberUnit
-numberDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addSensor
public OOCSIDevice addSensor(java.lang.String name, java.lang.String channel, java.lang.String sensorType, java.lang.String sensorUnit, float sensorDefault, java.lang.String icon)add a sensor component to this device- Parameters:
name
-channel
-sensorType
-sensorUnit
-sensorDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addSensor
public OOCSIDevice addSensor(java.lang.String name, java.lang.String channel, OOCSIDevice.SensorType sensorType, java.lang.String sensorUnit, float sensorDefault, java.lang.String icon)add a sensor component to this device- Parameters:
name
-channel
-sensorType
-sensorUnit
-sensorDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addBinarySensor
public OOCSIDevice addBinarySensor(java.lang.String name, java.lang.String channel, java.lang.String sensorType, boolean sensorDefault, java.lang.String icon)add a binary sensor component to this device- Parameters:
name
-channel
-sensorType
-sensorDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addBinarySensor
public OOCSIDevice addBinarySensor(java.lang.String name, java.lang.String channel, OOCSIDevice.BinarySensorType sensorType, boolean sensorDefault, java.lang.String icon)add a binary sensor component to this device- Parameters:
name
-channel
-sensorType
-sensorDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addSwitch
public OOCSIDevice addSwitch(java.lang.String name, java.lang.String channel, java.lang.String switchType, boolean switchDefault, java.lang.String icon)add a switch component to this device- Parameters:
name
-channel
-switchType
-switchDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addSwitch
public OOCSIDevice addSwitch(java.lang.String name, java.lang.String channel, OOCSIDevice.SwitchType switchType, boolean switchDefault, java.lang.String icon)add a switch component to this device- Parameters:
name
-channel
-switchType
-switchDefault
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addLight
public OOCSIDevice addLight(java.lang.String name, java.lang.String channel, java.lang.String lightType, java.lang.String spectrum, int min, int max, boolean lightDefault, int defaultBrightness, java.lang.String icon)add a sensor component to this device- Parameters:
name
-channel
-lightType
-spectrum
-min
-max
-lightDefault
-defaultBrightness
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
addLight
public OOCSIDevice addLight(java.lang.String name, java.lang.String channel, OOCSIDevice.LedType lightType, OOCSIDevice.LightSpectrum spectrum, int min, int max, boolean lightDefault, int defaultBrightness, java.lang.String icon)add a sensor component to this device- Parameters:
name
-channel
-lightType
-spectrum
-min
-max
-lightDefault
-defaultBrightness
-icon
- Get an icon from the set at: https://materialdesignicons.com/ Copy the title of the icon page- Returns:
-
submit
public void submit()submit the heyOOCSI! message to the server -
sayHi
public void sayHi()alternative call for submit() -
getState
public boolean getState(boolean defaultValue)retrieve the currently set state for the only component -- or default value- Parameters:
defaultValue
-- Returns:
-
getStateOfComponent
public boolean getStateOfComponent(java.lang.String componentName, boolean defaultValue)retrieve the currently set state for the given component -- or default value- Parameters:
defaultValue
-- Returns:
-
getValue
public float getValue(float defaultValue)retrieve the currently set value for the only component -- or default value- Parameters:
defaultValue
-- Returns:
-
getValue
public float getValue(java.lang.String key, float defaultValue)retrieve the currently set value for a given key for the only component -- or default value- Parameters:
defaultValue
-- Returns:
-
getValueOfComponent
public float getValueOfComponent(java.lang.String componentName, float defaultValue)retrieve the currently set default value for the given component -- or default value- Parameters:
componentName
-defaultValue
-- Returns:
-
getValueOfComponent
public float getValueOfComponent(java.lang.String componentName, java.lang.String key, float defaultValue)retrieve the currently set value for the given component and key -- or default value- Parameters:
componentName
-key
-defaultValue
-- Returns:
-
setState
public void setState(boolean state)set the default value for the only component- Parameters:
state
-
-
setValue
public void setValue(java.lang.Number value)set the default value for the only component- Parameters:
value
-
-
setValue
public void setValue(java.lang.String value)set the default value for the only component- Parameters:
value
-
-
setValue
public void setValue(java.lang.String key, java.lang.Number value)set the value for a given key for the only component- Parameters:
key
-value
-
-
setValue
public void setValue(java.lang.String key, java.lang.String value)set the value for a given key for the only component- Parameters:
key
-value
-
-
setValueForComponent
public void setValueForComponent(java.lang.String componentName, java.lang.Number value)set the default value for the given component- Parameters:
componentName
-value
-
-
setValueForComponent
public void setValueForComponent(java.lang.String componentName, java.lang.String value)set the default value for the given component- Parameters:
componentName
-value
-
-
setValueForComponent
public void setValueForComponent(java.lang.String componentName, java.lang.String key, boolean value)set a value for the given component- Parameters:
componentName
-key
-value
-
-
setValueForComponent
public void setValueForComponent(java.lang.String componentName, java.lang.String key, java.lang.Number value)set a value for the given component- Parameters:
componentName
-key
-value
-
-
setValueForComponent
public void setValueForComponent(java.lang.String componentName, java.lang.String key, java.lang.String value)set a value for the given component- Parameters:
componentName
-key
-value
-
-