# myShelly main

from myShelly import myShelly
from myShelly.block import Block
from myShelly.relay import Relay


def device_added(dev,code):
  print ('DEVICE' , dev,":",code)
  for key, value in dev.__dict__.items():
    print('%s = %s' % (key, value))
shelly = myShelly()
print("Version:",shelly.version())

shelly.cb_device_added.append(device_added)
shelly.start()

r1b = Block(shelly, '12345', 'SHSW-1', '192.168.168.110', None)
u1b = Block(shelly, '12345', 'SHUNI-1', '192.168.168.101', None)
print('== SHELLY ==')
for key, value in shelly.__dict__.items():
  print('%s = %s' % (key, value))
print('== R1B ==')
for key, value in r1b.__dict__.items():
  print('%s = %s' % (key, value))

r1 = Relay(r1b, 0)
print('== R1 ==')
for key, value in r1.__dict__.items():
  print('%s = %s' % (key, value))

r1.turn_off()
print(r1.friendly_name())