Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95387

Smart-me switch and sensor with rest api

$
0
0

@koni wrote:

Hi everybody,

i try to use my smart-me switch which has a rest-api:
https://smart-me.com/swagger/ui/index#!/Actions/Actions_Post

i got so far to use the sensor to connect to the api and not throw an error, but the value are not available in the overview (or rather they are undefined):

sensor:
  - platform: rest
    name: smartmesensor
    json_attributes:
        - Id
        - Name
        - Serial
        - DeviceEnergyType
        - FamilyType
        - ActivePower 
        - ActivePowerUnit
        - CounterReading
        - CounterReadingUnit
        - CounterReadingT1
        - CounterReadingImport
        - SwitchON
        - Voltage
        - VoltageL1
        - Current
        - PowerFactor
        - PowerFactorL1
        - Temperature
        - ValueDate
    resource: https://smart-me.com:443/api/Device/***DEVICE-ID***
    authentication: basic
    username: ***my_username***
    password: ***my_passwort***
    value_template: 'ok'
  - platform: template
    sensors:
      sm_activepower:
        value_template: '{{states.sensor.smartmesensor.attributes["ActivePower"] }}'
        device_class: power
        unit_of_measurement: 'kWh'
      sm_voltage:
        value_template: '{{states.sensor.smartmesensor.attributes["Voltage"] }}'
        unit_of_measurement: 'V'
      sm_counterreading:
        value_template: '{{states.sensor.smartmesensor.attributes["CounterReading"] }}'
        device_class: power
        unit_of_measurement: 'kWh'
      sm_current:
        value_template: '{{states.sensor.smartmesensor.attributes["Current"] }}'
        unit_of_measurement: 'A'
      sm_switchon:
        value_template: '{{states.sensor.smartmesensor.attributes["SwitchON"] }}'

the answer of the rest-api is:

{
  "Id": "string",
  "Name": "string",
  "Serial": 0,
  "DeviceEnergyType": "MeterTypeUnknown",
  "MeterSubType": "MeterSubTypeUnknown",
  "FamilyType": "MeterFamilyTypeUnknown",
  "ActivePower": 0,
  "ActivePowerL1": 0,
  "ActivePowerL2": 0,
  "ActivePowerL3": 0,
  "ActivePowerUnit": "string",
  "CounterReading": 0,
  "CounterReadingUnit": "string",
  "CounterReadingT1": 0,
  "CounterReadingT2": 0,
  "CounterReadingT3": 0,
  "CounterReadingT4": 0,
  "CounterReadingImport": 0,
  "CounterReadingExport": 0,
  "SwitchOn": true,
  "SwitchPhaseL1On": true,
  "SwitchPhaseL2On": true,
  "SwitchPhaseL3On": true,
  "Voltage": 0,
  "VoltageL1": 0,
  "VoltageL2": 0,
  "VoltageL3": 0,
  "Current": 0,
  "CurrentL1": 0,
  "CurrentL2": 0,
  "CurrentL3": 0,
  "PowerFactor": 0,
  "PowerFactorL1": 0,
  "PowerFactorL2": 0,
  "PowerFactorL3": 0,
  "Temperature": 0,
  "ActiveTariff": 0,
  "DigitalOutput1": true,
  "DigitalOutput2": true,
  "AnalogOutput1": 0,
  "AnalogOutput2": 0,
  "DigitalInput1": true,
  "DigitalInput2": true,
  "ValueDate": "2020-04-03T19:15:18.557Z",
  "AdditionalMeterSerialNumber": "string",
  "FlowRate": 0
}

Additionally i try to use the switch feature:

switch:
  - platform: rest
    name: smartme
    resource: https://smart-me.com:443/api/Actions
    username: ***username***
    password: ***passwort
    body_on:  '{"DeviceID": "***device-id****","Actions": [{"ObisCode": "***obiscode***","Value": 1}]}'
    body_off: '{"DeviceID": "***device-id***","Actions": [{"ObisCode": "***obiscode***","Value": 0}]}'
    headers:
      Content-Type: application/json
      authentication: basic

with the message being:

{
  "DeviceID": "string",
  "Actions": [
    {
      "ObisCode": "string",
      "Value": 0
    }
  ]
}

i get the following error about the switch function:
2020-04-03 21:08:17 ERROR (MainThread) [homeassistant.components.rest.switch] Got non-ok response from resource: 405

Thanks for helping

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>