Switch#

Every entity in picoides.io has it related state object. It s a representation of device state describing basic and more specific properties of a device.

Example

switch device state object

{
  "attributes": {
    "active_total_energy_kwh": "2469.72",
    ...
    "assumed_state": true,
    ...
    "friendly_name": "picoides_gw_4_2",
    "last_update": "2018-12-13T13:08:07.128504+00:00",
    "latitude": "52.1737",
    "longitude": "20.81292",
    ...
    "reactive_total_energy_varh": "454365.75",
    "time_from_01_01_2000_in_seconds": "598123584.00",
    ...
    "voltage_between_line_1_and_line_2": "401.60",
    "voltage_between_line_2_and_line_3": "400.87",
    "voltage_between_line_3_and_line_1": "399.72",
    "voltage_line_1": "231.26",
    "voltage_line_2": "231.14",
    "voltage_line_3": "230.47"
  },
  "entity_id": "switch.picoides_gw_4_2",
  "last_changed": "2018-12-13T13:08:07.122457+00:00",
  "last_updated": "2018-12-13T13:08:07.129167+00:00",
  "state": "off"
}

Note

entity_id - links state object to entity

States#

state param#

the state param of state object describes the most basic status of device if it's on or off...

Example

state property of state object

{
  ...
  "state": "on"
  ...
}

picoides.io devices of switch domain can take states values listed below:

  • on - device relay is on *
  • off - device relay is off *
  • unknown - state was not set *
  • problem - state is or should be known to the system but device reports errors
  • unavailable - device is registered in system but not yet connected

Note

state of switch may equal to real on or off or to last_set_state

state attributes#

state attributes describe additional device parameters

Example

state attributes of switch

{
  ...
  "attributes": {
    "assumed_state": true,
    "area": "",
    "current_power_w": 100,
    "friendly_name": "dev no 3",
    "latitude": 0,
    "longitude": 0,
    "today_energy_kwh": 15
  },
  ...
}

Extra features attributes#

Some switch devices are installed with extra module like power meter. Parameters monitored by additional equipment extend state attribute object. Details may vary on implementation on equipment used and it setup.

Supported features are described by supported_features filed. It is a 16-bit bitfield value. Id bit is set device supports feature

bit feature description
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 POWERMETER can return power supply related information

Example

state attributes of switch with assigned powermeter

{
  "active_power_line_1_watt": "551.66",
  "active_power_line_2_watt": "421.49",
  "active_power_line_3_watt": "689.57",
  "active_total_energy_kwh": "2469.72",
  "active_total_energy_wh": "2469717.75",
  "apparent_power_line_1_va": "566.23",
  "apparent_power_line_2_va": "422.99",
  "apparent_power_line_3_va": "704.82",
  "apparent_total_energy_vah": "2511166.00",
  "combined_active_power_line_123": "1665.49",
  "combined_apparent_power_line_123": "1766.38",
  "combined_power_factor_for_line_123": "0.97",
  "combined_power_factor_for_line_123_l_c": "0.98",
  "combined_reactive_power_line_123": "280.56",
  "current_in_line_1": "2.46",
  "current_in_line_2": "2.04",
  "current_in_line_3": "2.85",
  "current_neutral_line": "0.74",
  "date_time_win_format": "6922.00",
  "frequency_line_1_hrz": "50.01",
  "frequency_line_2_hrz": "50.01",
  "frequency_line_3_hrz": "50.03",
  "power_factor_line_1_l_c": "0.97",
  "power_factor_line_1_pf": "0.97",
  "power_factor_line_2_l_c": "0.99",
  "power_factor_line_2_pf": "1.00",
  "power_factor_line_3_l_c": "0.98",
  "power_factor_line_3_pf": "0.96",
  "reactive_power_line_1_var": "127.54",
  "reactive_power_line_2_var": "39.69",
  "reactive_power_line_3_var": "178.53",
  "reactive_total_energy_varh": "454365.75",
  "time_from_01_01_2000_in_seconds": "598123584.00",
  "voltage_between_line_1_and_line_2": "401.60",
  "voltage_between_line_2_and_line_3": "400.87",
  "voltage_between_line_3_and_line_1": "399.72",
  "voltage_line_1": "231.26",
  "voltage_line_2": "231.14",
  "voltage_line_3": "230.47"
  }

Services#

turn_on#

Example

$ curl -X POST -u "testuser:YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"entity_id": ["switch.dev_unique_name_2"], "brightness": 105}' \
       http://localhost:8123/api/services/switch/turn_on

turn_off#

Example

$ curl -X POST -u "testuser:YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"entity_id": ["switch.dev_unique_name_2"]}' \
       http://localhost:8123/api/services/switch/turn_off

toggle#

Example

$ curl -X POST -u "testuser:YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"entity_id": ["switch.dev_unique_name_1", "switch.dev_unique_name_2"]}' \
       http://localhost:8123/api/services/switch/toggle

poll#

Will poll state of switch (relay) and assigned powermeter sensor (if any)

Example

poll state of switch

$ curl -X POST  -u "testuser:YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"entity_id": ["switch.dev_unique_name_2"]}' \
       http://localhost:8123/api/services/switch/picoides_poll