Package: python-mystrom
Asynchronous Python API client for interacting withmyStromdevices.This module is not official, developed, supported or endorsed by myStrom AG.
For questions and other inquiries, use the issue tracker in this repo please.Without the support of myStrom AG it would have taken much longer to create
this module which is the base for the integration intoHome Assistant. myStrom AG has provided hardware.
Their continuous support make further development of this module possible.RequirementsYou need to havePythoninstalled.myStromdevice (bulb, plug or button)Thepython-mystromrequirementsNetwork connectionDevices connected to your networkInstallationThe package is available in thePython Package Index.$pip3installpython-mystromOn a Fedora-based system or on a CentOS/RHEL machine which has EPEL enabled.$sudodnf-yinstallpython3-mystromFor Nix or NixOS users is a package available. Keep in mind that the lastest releases might only
be present in theunstablechannel.$nix-env-iAnixos.python3Packages.python-mystromPlug/switchAt the moment the following endpoints are covered accordinghttps://api.mystrom.ch:/report: for getting the current state and the power consumption/relay: for setting the relay stateYou will still be able to use your device with the smartphone application,curlor other tools. The samples below shows how to use the switch withhttpieandcurlalong withpython-mystrom.$httphttp://IP_ADDRESS_PLUG/reportHTTP/1.1200OKContent-Length:39Content-Type:application/jsonDate:Mon,15Feb201617:52:21GMT{"power":51.630947,"relay":true}$curl-XGEThttp://IP_ADDRESS_PLUG/relay?state=1BulbIf the bulb is on then you should be able to retrieve the current state of
the bulb.Browse tohttp://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBor use a
command-line tool.$curl-d"color=0;0;100"-d"action=on"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULB{"5DFF7FAHZ987":{"on":true,"color":"0;0;100","mode":"hsv","ramp":100,"notifyurl":""}}The bulbs are not able to handle payload formatted as JSON. It’s required to
useapplication/x-www-form-urlencoded. Keep that in mind if something is
not working, especially around setting the color with HSV.If you are planning to use your bulbs withHome Assistantset the bulb to a state fromColorswith the app or use the command below.$curl-d"color=0;0;100"IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBSet StateYou can set the state with a POST request and a payload.on:curl-d"action=on"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBoff:curl-d"action=off"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBtoggle:$ curl-d"action=toggle"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBSet Color RGBOne of the supported modes for setting the color isRBG.white:$ curl-d"color=FF000000"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBred:$ curl-d"color=00FF0000"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBgreen:$ curl-d"color=0000FF00"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBblue:$ curl-d"color=000000FF"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBSet Color HSV (Hue, Saturation, Value)It’s also possible to useHSV.$curl-d"color=0;0;100"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBWhile “color=” is composed with hue, saturation, and value.Set Mono (white)If you only want to set the “white” color of the bulb, usemono.$curl-d"color=10;100"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULB“color=” contains the value for the color temperature (from 1 to 18) and the
brightness (from 0 to 100).Dimming (ramp)Addrampand an interval to set up the transition time while changing
colors.$curl-d"action=on&ramp=1000&color=00FF0000"http://IP_ADDRESS_BULB/api/v1/device/MAC_ADDRESS_BULBThe unit of measurement for ramp is milliseconds (ms).ButtonThe buttons can be set with the myStrom app or directly via HTTP requests.To set the configuration the payload must contains the relevant details for
the actions:$ curl-v-d"single=<url>&double=<url>&long=<url>&touch=<url>"http://IP_ADDRESS_BUTTON/api/v1/device/MAC_ADDRESS_BUTTONAvailable actions:single: Short push (approx. 1/2 seconds)double: 2x sequential short pushes (within 2 seconds)long: Long push (approx. 2 seconds)touch: Touch of the button’s surface (only affective for the WiFi
Button +)The button is set up to extend the life span of the battery as much as
possible. This means that only within the first 3 minutes or when connected
to an USB port/USB charger and the battery is not full, the button is able
to receive configuration information or publish its details.mystromhelper toolThe command-line toolmystromcan help to set up the buttons and get the
details from bulbs and plugs.$mystromUsage:mystrom[OPTIONS]COMMAND[ARGS]...Simplecommand-linetooltogetandsetthevaluesofamyStromdevices.ThistoolcansetthetargetsofamyStrombuttonforthedifferentavailableactionssingle,double,longandtouch.Options:--versionShowtheversionandexit.--helpShowthismessageandexit.Commands:bulbGetandsetdetailsofamyStrombulb.buttonGetandsetdetailsofamyStrombutton.configGetandsettheconfigurationofamyStrom...The examples shows how to get the details of a given bulb.$mystromconfigreadIPaddressofthemyStromdevice:IP_ADDRESS_BULBMACaddressofthedevice:MAC_ADDRESS_BULBReadconfigurationfromIP_ADDRESS_BULB{'MAC_ADDRESS_BULB':{'type':'rgblamp','battery':False,'reachable':True,'meshroot':False,'on':True,'color':'191;90;14','mode':'hsv','ramp':100,'power':0.953,'fw_version':'2.25'}}Example usage of the moduleExamples for the bulb can be found in the directoryexamples.Licensepython-mystromis licensed under MIT, for more details check LICENSE.