Example

The sample below shows how to use this Python module.

importpymystromplug=pymystrom.MyStromPlug('IP_ADDRESS_PLUG')# Preserve stateSTATE_ON=plug.get_relay_state()# Switch relay on if the plug is currently offifnotSTATE_ON:print('Relay will be switched on.')plug.set_relay_on()# Wait a few seconds to get a reading of the power consumptionprint('Waiting for a couple of seconds...')time.sleep(10)# Get the new state of the switchprint('Relay state: ',plug.get_relay_state())print('Power consumption:',plug.get_consumption())# Switch relay off if it was off.ifnotSTATE_ON:plug.set_relay_off()