MiCasaVerde Vera UI5, UI6, UI7 Plugin

Questions and comments specific to a particular plugin should go here.
holdestmade
Experienced User
Posts: 164
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade » Wed Nov 29, 2017 3:33 pm

I did the same, just ran the build process and that worked fine as long as the folder didn't exist.

Even after that, the commands:

from micasaverde_vera import Vera
vera = Vera('192.168.1.205')

causes it to re-run the build process and has an error in the log at the beginning before the build log entries.

Does that make sense ?

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Wed Nov 29, 2017 6:52 pm

ok So I changed the detection of when the build process needs to be run. instead of simply checking if the folder exists. I now have it try to import a file from the build directory and if it can't then it will rerun the build. Now... I am going to change it to be global for all core files. but this is to make sure it works properly before i go and override the builtin python __import__ I have to try and work out the mechanics of it. because i need to change how the building gets done mid way through the startup.

latest version is up on my repo.

Oh. I also fixed the double variable crap but I may have broken other things along the way. I do not know yet. But the events are working just fine. and setting variables like Status work fine as well. even if there are more then one variable with the same name.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Wed Nov 29, 2017 7:13 pm

it does make complete sense. this was happening because i started a thread that would run the build process. and the thread that started the build thread would print a '.' every second until the build thread was finished. but to get this to work properly I needed to flush the output buffer using flush(). which was not coded into EG. so I am not able to print the '.'s to let you know it is actually doing something. so you will have to simply sit there and wait until you get a build complete message.


also. the way you are running the library is only going to start the build process and then terminate unless you specifically create the Vera instance in a global or specify an event callback and have that event callback put as a global it's not going to do much

Code: Select all


from micasaverde_vera import Vera
eg.globals.vera = Vera()

doing this will allow you to now access the created instance from any other script. so as an example.. if you wanted to add it to a macro so when you turn your TV on it will turn off the lights. You would add a python script to the macro that has the event for the TV turning on. and in that script you would put

Code: Select all

eg.globals.vera.get_device('SOME DEVICE NAME').Status = 0
or

Code: Select all

eg.globals.vera.get_device('SOME DEVICE NAME').set_target(0)

or if you wanted to change the level of the light

Code: Select all

eg.globals.vera.get_device('SOME DEVICE NAME').LoadLevelTarget = 10
or

Code: Select all

eg.globals.vera.get_device('SOME DEVICE NAME').get_load_level_target(10)

if you wanted to do things based on specific events from a device you would start Verasimilar to this. this is going to check a light level and if it has changed to on then it will turn some other light off.

Code: Select all

from micasaverde_vera import Vera

def callback(event):
    if event.Status == 1:
        eg.globals.vera.get_device('SOME_OTHER_DEVICE').Status = 0
        
eg.globals.callback = callback

eg.globals.vera = Vera()
eg.globals.vera.bind('Device.DEVICE_NUMBER.SwitchPower1.Status.Changed', eg.globals.callback)
you will want to replace the DEVICE_NUMBER with the number of the device to monitor for a status change. and change the SOME_OTHER_DEVICE to another light to turn off when the DEVICE_NUMBER device has turned on

Instead of using device names in the get_device I would recommend using the device numbers. as these numbers never get reused and will always stay the same. where as the name can change (if you change it on the Vera. you can pass the number to get_device as a number or a string. so 1 and '1' will both work.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Thu Nov 30, 2017 8:07 am

OK i have updated the repo again. I have changed up some of the file building and i also set up a mechanism that will add any missing files as an example. you install a new plugin. this is going to download files to the vera from MIOS. when these new files arrive and the plugin is installed then the library will go and build those files. or if a generated file gets deleted it will be rebuilt. I am gong to build in a fallback that will remove all of the generated files and rebuild them all. in the event there is some other issue. file corruption. someone modified one of the files and it's causing an error.
If you like the work I have been doing then feel free to Image

holdestmade
Experienced User
Posts: 164
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade » Thu Nov 30, 2017 5:08 pm

Hey,

Don't know if I'm being thick and missing something but can't get this to work.
Sorry, I am not that experienced with this but trying to learn from you !
Thanks for your patience.


Got the build working ok with:

Code: Select all

from micasaverde_vera import vera_build
vera_build.build_files('192.168.1.205', log=True)
This created all the files OK.

As soon as I try:

Code: Select all

from micasaverde_vera import Vera
eg.globals.vera = Vera()
EG hangs and I need to restart it (waited for 10 mins)

I tried:

Code: Select all

from micasaverde_vera import Vera
eg.globals.vera = Vera('192.168.1.205')
and got this error:

17:06:16 Traceback (most recent call last):
17:06:16 Python script "3", line 25, in <module>
17:06:16 eg.globals.vera = Vera('192.168.1.205')
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 273, in __new__
17:06:16 return NewVera(ip_address)
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 249, in __init__
17:06:16 _Vera.__init__(self, ip)
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 336, in __init__
17:06:16 self.devices = self.__build(Devices, 'devices', data)
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 386, in __build
17:06:16 data.pop(key, None)
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\devices.py", line 34, in __init__
17:06:16 self._devices += [self.__build(device)]
17:06:16 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\devices.py", line 53, in __build
17:06:16 'micasaverde_vera.core.devices.' + mod_name
17:06:16 File "importlib\__init__.pyc", line 38, in import_module
17:06:16 KeyError: 'micasaverde_vera.core.devices.'

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Fri Dec 01, 2017 2:00 am

i may need you to send me a copy of your user data again. I am going to check the one you sent me. but it appears as tho you have a device that does not have a service id.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Fri Dec 01, 2017 2:15 am

yup. You have 2 devices that are UPNP devices. and they have no name and no device_type I think it is loony tunes that the Vera allows you to add upnp devices even tho it does not do anything with them the only purpose for the upnp is if you have a second Vera controller.

The real kicker is that they are invisible. LOL. Here is the data on the devices.

Code: Select all

device id="373"
	name=""
	pnp="5291"
	device_type=""
	id_parent="203"
	disabled="0"
	device_file=""
	device_json=""
	impl_file=""
	manufacturer=""
	model=""
	altid="e1"
	ip=""
	mac=""
	time_created="1498138562"
	embedded="1"
	invisible="1"
	room="1"
         
device id="374"
	name=""
	pnp="5301" 
	device_type="" 
	id_parent="203" 
	disabled="0" 
	device_file="" 
	device_json="" 
	impl_file="" 
	manufacturer="" 
	model="" 
	altid="e2" 
	ip="" 
	mac="" 
	time_created="1498138562" 
	embedded="1" 
	invisible="1" 
	room="1"
You will need to enter these 2 commands into your browser. This will delete the bad devices

Code: Select all

http:\\YOUR_VERA_IP:3480\data_request?id=action&action=DeleteDevice&serviceId=urn:micasaverde-com:deviceId:HomeAutomationGateway1&DeviceNum=373

http:\\YOUR_VERA_IP:3480\data_request?id=action&action=DeleteDevice&serviceId=urn:micasaverde-com:deviceId:HomeAutomationGateway1&DeviceNum=374
I will also code a way around it.
If you like the work I have been doing then feel free to Image

blaher
Experienced User
Posts: 481
Joined: Thu Nov 17, 2011 1:27 am

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by blaher » Fri Dec 01, 2017 4:57 am

kgschlosser wrote:
Wed Nov 22, 2017 11:28 am

I set up a repository for it HERE.
This would be good at the top of the very first post. I'll give it a go too when I can. Cheers!

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Fri Dec 01, 2017 5:22 am

The reason this it is not on the first post is because it is not a plugin.

It is a python library. I will be making a eventghost front end for it as soon as I know it is free of most glitches.

Also the repo has been updated to handle the issue with the missing device_type. so we should be good to go there.

I am hoping this is the last hurdle. but for some strange reason i am thinking that is not going to be the case.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Fri Dec 01, 2017 6:50 am

ok repo updated again. I added generated file versioning and rebuilding of the files if the versioning does not match the current version of the library.


***EDIT***

I also added checking for file corruption/file alteration on the generated files. if they are not originals then they will be rebuilt.
If you like the work I have been doing then feel free to Image

holdestmade
Experienced User
Posts: 164
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade » Fri Dec 01, 2017 8:58 am

kgschlosser wrote:
Fri Dec 01, 2017 2:15 am
yup. You have 2 devices that are UPNP devices. and they have no name and no device_type I think it is loony tunes that the Vera allows you to add upnp devices even tho it does not do anything with them the only purpose for the upnp is if you have a second Vera controller.

The real kicker is that they are invisible. LOL. Here is the data on the devices.

Code: Select all

device id="373"
	name=""
	pnp="5291"
	device_type=""
	id_parent="203"
	disabled="0"
	device_file=""
	device_json=""
	impl_file=""
	manufacturer=""
	model=""
	altid="e1"
	ip=""
	mac=""
	time_created="1498138562"
	embedded="1"
	invisible="1"
	room="1"
         
device id="374"
	name=""
	pnp="5301" 
	device_type="" 
	id_parent="203" 
	disabled="0" 
	device_file="" 
	device_json="" 
	impl_file="" 
	manufacturer="" 
	model="" 
	altid="e2" 
	ip="" 
	mac="" 
	time_created="1498138562" 
	embedded="1" 
	invisible="1" 
	room="1"
You will need to enter these 2 commands into your browser. This will delete the bad devices

Code: Select all

http:\\YOUR_VERA_IP:3480\data_request?id=action&action=DeleteDevice&serviceId=urn:micasaverde-com:deviceId:HomeAutomationGateway1&DeviceNum=373

http:\\YOUR_VERA_IP:3480\data_request?id=action&action=DeleteDevice&serviceId=urn:micasaverde-com:deviceId:HomeAutomationGateway1&DeviceNum=374
I will also code a way around it.
Hi, tried this and found they are slave devices for a Fibaro Dimmer switch I have.
The parent, 203 is the dimmer switch.
If I delete them they just re-appear as different device numbers on restart of Luup.
I've temporary installed AltUI in Vera as that shows up all devices, even invisible ones.

Cheers

holdestmade
Experienced User
Posts: 164
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade » Fri Dec 01, 2017 9:11 am

Tried the latest and the build is much faster at retrieving the files.

Code: Select all

from micasaverde_vera import Vera
eg.globals.vera = Vera()
This restarts the build process every time but adds this first:

09:04:59 Category | Category Name | Subcategory | Subcategory Name
09:04:59 ========================================================================================
09:04:59 0 Interfaces & Misc Devices
09:04:59 1 Interfaces & Misc Devices
09:04:59 2 Dimmable Switch
09:04:59 1 Dimmable Light Bulb
09:04:59 2 Dimmable Light Plugged
09:04:59 3 In Wall Dimmer
09:04:59 4 Colored Light
09:04:59 3 On/Off Switch
09:04:59 1 Indoor Switch
09:04:59 2 Outdoor Switch
09:04:59 3 In Wall Switch
09:04:59 4 Refrigerator Switch
09:04:59 5 Garage Door Switch
09:04:59 4 Security Sensor
09:04:59 1 Door & Window Sensor
09:04:59 2 Flood Sensor
09:04:59 3 Motion Sensor
09:04:59 4 Smoke Sensor
09:04:59 5 CO Sensor
09:04:59 6 Glass Break Sensor
09:04:59 5 Thermostat
09:04:59 1 Thermostat
09:04:59 2 Heater
09:04:59 3 Nest Thermostat
09:04:59 6 Camera
09:04:59 7 Poly-Control Danalock
09:04:59 8 Window Covering
09:04:59 9 Remote control
09:04:59 10 IR TX
09:04:59 11 I/O Device
09:04:59 2 Z-Wave Extender/Repeater
09:04:59 12 Sensor
09:04:59 13 Serial Port
09:04:59 14 Scene Controller
09:04:59 15 A/V Device
09:04:59 16 Humidity Sensor
09:04:59 17 Temperature Sensor
09:04:59 18 Light Sensor
09:04:59 19 Z-Wave Interface
09:04:59 20 Insteon Interfaces
09:04:59 21 Power Meter
09:04:59 22 Alarm Panel
09:04:59 23 Alarm Area
09:04:59 24 Alarm Siren
09:04:59 25 Weather Station
09:04:59 26 Philips Controller
09:04:59 27 Appliances
09:04:59 28 UV Sensor
09:04:59 9999 Scenes
09:05:00 Traceback (most recent call last):
09:05:00 Python script "5", line 26, in <module>
09:05:00 eg.globals.vera = Vera('192.168.1.205')
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 290, in __new__
09:05:00 return NewVera(ip_address)
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 266, in __init__
09:05:00 _Vera.__init__(self, ip)
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 353, in __init__
09:05:00 self.devices = self.__build(Devices, 'devices', data)
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\__init__.py", line 408, in __build
09:05:00 data.pop(key, None)
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\devices.py", line 34, in __init__
09:05:00 self._devices += [self.__build(device)]
09:05:00 File "C:\Program Files (x86)\EventGhost\lib27\site-packages\micasaverde_vera\devices.py", line 61, in __build
09:05:00 cls_name[:1].upper() + cls_name[1:]
09:05:00 AttributeError: 'module' object has no attribute 'ECO_Switch1'


Can also confirm if files exist it shows in the log they do:

09:05:19 -File Exists C:\Users\SIMON\AppData\Roaming\MiCasaVerde_Vera\services\v_switch_1.py etc

Code: Select all

from micasaverde_vera import vera_build
vera_build.build_files('192.168.1.205', log=True)
This restarted the build process and stopped at:

09:09:46 Building Templates....

Thanks for the message BTW, at least I know I'm not going mad...

Cheers

holdestmade
Experienced User
Posts: 164
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade » Tue Dec 05, 2017 8:52 am

So, finally got round to test the latest version and it works without errors.

Build goes fine, all files written, done in approx 30 seconds.

On first run with (only needed to do this once):

Code: Select all

from micasaverde_vera import Vera
eg.globals.vera = Vera('196.168.1.205')
It 'hangs' EG and CPU goes up to ~50% for ~30 seconds.

Then, using scripts with several calls from you examples, turns on lights etc and gets variables fine; there are some delays though, sometimes up to 15 seconds.

One issue I can't seem to work out is lights that are controlled though my RFXTRX (RF light switches) go from 0 to 55% (sometimes 65%), then 90%, then 100%, with about a 2-3 second delay between each level !

Zwave lights and sensors respond almost instantly, Yeelight (with another python library) have a 1-2 second delay.

I need to try a bit more scripting to interface with my RTI remote processor and I'll report back.

Cheers

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Tue Dec 05, 2017 2:46 pm

holdestmade wrote:
Tue Dec 05, 2017 8:52 am
So, finally got round to test the latest version and it works without errors.
Build goes fine, all files written, done in approx 30 seconds.
this is a good thing but 30 seconds is a bit long for this process to be taking it should take about 15 seconds or so.
holdestmade wrote:
Tue Dec 05, 2017 8:52 am
It 'hangs' EG and CPU goes up to ~50% for ~30 seconds.
Does this take place only during the build process?. so if you run the script again is there still a hang?

holdestmade wrote:
Tue Dec 05, 2017 8:52 am
Then, using scripts with several calls from you examples, turns on lights etc and gets variables fine; there are some delays though, sometimes up to 15 seconds.
I would need a tidbit more information on this. One of the things you need to remember is that there are variables which when set on the Vera causes the Lua engine to restart. this is out of my control. another thing is scenes. if a specific device that you are changing is attached to a scene on the vera it is also going to run/check any of the data for that as well. and as we know the scene system on the Vera is extremely Special Ed

holdestmade wrote:
Tue Dec 05, 2017 8:52 am
One issue I can't seem to work out is lights that are controlled though my RFXTRX (RF light switches) go from 0 to 55% (sometimes 65%), then 90%, then 100%, with about a 2-3 second delay between each level !
again I need a more detailed explanation. How are you setting the light level?, using the function or the variable? have you tried both ways to see if there is a performance difference? The RF lights on the vera are controlled via a plugin yes? if they are then in that plugin there would be a polling loop to check the state of the devices. this same polling mechanism might also control the variable changes. if there is a setting for the polling speed. change it and report back.

here is a hint for ya!

Code: Select all

device = vera.get_device(20)
print '-------- {0} Functions --------'.format(device.name)
for item in device.get_device_functions():
    print item
print
print
print '-------- {0} Variables --------'.format(device.name)
for item in device.get_device_variables():
    print item
the above code will print out all of the variables and functions that are available to a specific device.
holdestmade wrote:
Tue Dec 05, 2017 8:52 am
I need to try a bit more scripting to interface with my RTI remote processor and I'll report back.
I would say hold off on this and lets hammer out the existing problems before adding more complexity.
If you like the work I have been doing then feel free to Image

User avatar
kgschlosser
Site Admin
Posts: 4289
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser » Fri Dec 08, 2017 5:17 am

ok I have updated the repo once again.

Things have changed quite a bit. This is due to me working on the actual plugin.

to use the library now you will need to follow the code below to get it started.

Code: Select all

import micasaverde_vera
vera = micasaverde_vera.connect('192.168.1.1')


This wonderful little bit of code below will get Events going in EG for ya

Code: Select all

import threading

def run():
    import micasaverde_vera

    def callback(event):
        if "LuaUPnPAlive" in event.event:
            return
        evt = event.event.replace('vera.', '')
        if evt.endswith('changed'):
            split_event = evt.split('.')[:-1]
            value = getattr(event, split_event[-1])
            try:
                value = getattr(value, 'name')
            except:
                pass
        
            split_event += [str(value)]
            eg.TriggerEvent(prefix='Vera', suffix='.'.join(split_event), payload=event)
        else:
            eg.TriggerEvent(prefix='Vera', suffix=evt, payload=event)
        
    eg.globals.vera = vera = micasaverde_vera.connect()
    vera.bind('*', callback)
    vera.start_polling(0.5)
    
threading.Thread(target=run).start()
eg.globals.vera can be used to control the Vera

I attached the vera object where the event occurred as a payload
If you like the work I have been doing then feel free to Image

Post Reply