Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

MiCasaVerde Vera UI5, UI6, UI7 Plugin

Questions and comments specific to a particular plugin should go here.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

ok. scratch that last post


put this into a python script. change the IP_ADDRESS.. you know the drill... LOL

this is going to create a folder on your desktop called BUILD_OUTPUT. zip up that whole folder and send it to me in a PM. it is going to have some stuff in there which i do not want to be in a public forum.

The script each time it is run will delete the old files and create new ones. these are exact duplicates of the device and service files on the vera. as well as that category stuff. these are common files to different vera models. but the vera.xml file is the one that will have things like your unit serial number and home id in them. hence the sending it to me in a PM.

This is going to tell you exactly what it is getting and where it is putting it. and if removing something it is going to tell you what it is removing (stale file from a previous run of this script)

This is going to take a bit for EG to run. and EG is going to say to you NOT RESPONDING. so ignore the not responding and let it go. EG will return to normal once this is finished.

Code: Select all

IP_ADDRESS = ''


import os
import requests


URL = 'http://{0}/cgi-bin/cmh/'.format(IP_ADDRESS)
GET_UPNP_FILES = URL + 'get_upnp_files.sh'
VIEW_UPNP_FILE = URL + 'view_upnp_file.sh?file={file}'
SYS_INFO = URL + 'sysinfo.sh'
CATEGORIES = 'http://{0}/cmh/js/config/constants.js'.format(IP_ADDRESS)
CATEGORY_LANG = 'http://{0}/cmh/js/config/lang.js'.format(IP_ADDRESS)
VERA_INFO = 'http://{0}/upnp/vera.xml'.format(IP_ADDRESS)



BASE_FOLDER = os.path.join(
    os.path.expandvars('%USERPROFILE%'),
    'Desktop',
    'BUILD_OUTPUT'
)


CGI_FOLDER = os.path.join(BASE_FOLDER, 'cgi-bin', 'cmh')
CATEGORY_FOLDER = os.path.join(BASE_FOLDER, 'cmh', 'js', 'config')
UPNP_FOLDER = os.path.join(BASE_FOLDER, 'upnp')


if not os.path.exists(BASE_FOLDER):
    print 'Creating folder', BASE_FOLDER
    os.mkdir(BASE_FOLDER)


if os.path.exists(CGI_FOLDER):
    for f in os.listdir(CGI_FOLDER):
        f = os.path.join(CGI_FOLDER, f)
        print 'Removing old data file', f
        os.remove(f)
else:
    print 'Creating folder', CGI_FOLDER
    os.makedirs(CGI_FOLDER)

if os.path.exists(CATEGORY_FOLDER):
    for f in os.listdir(CATEGORY_FOLDER):
        f = os.path.join(CATEGORY_FOLDER, f)
        print 'Removing old data file', f
        os.remove(f)
else:
    print 'Creating folder', CATEGORY_FOLDER
    os.makedirs(CATEGORY_FOLDER)

if os.path.exists(UPNP_FOLDER):
    for f in os.listdir(UPNP_FOLDER):
        f = os.path.join(UPNP_FOLDER, f)
        print 'Removing old data file', f
        os.remove(f)
else:
    print 'Creating folder', UPNP_FOLDER
    os.makedirs(UPNP_FOLDER)

constants = os.path.join(CATEGORY_FOLDER, 'constants.js')
lang = os.path.join(CATEGORY_FOLDER, 'lang.js')
vera = os.path.join(UPNP_FOLDER, 'vera.xml')

print 'Getting file constants.js'
response = requests.get(CATEGORIES)
print 'Writing file', constants
with open(constants, 'w') as f:
    f.write(response.content)

print 'Getting file lang.js'
response = requests.get(CATEGORY_LANG)
print 'Writing file', lang
with open(lang, 'w') as f:
    f.write(response.content)

print 'Getting file vera.xml'
response = requests.get(VERA_INFO)
print 'Writing file', vera
with open(vera, 'w') as f:
    f.write(response.content)

print 'Getting upnp file list'
response = requests.get(GET_UPNP_FILES)
file_list = response.content

for data_file in file_list.split('\n'):
    if data_file and 'xml.lzo' in data_file:
        print 'Getting file', data_file
        response = requests.get(VIEW_UPNP_FILE.format(file=data_file))
        data_file = os.path.join(CGI_FOLDER, data_file.replace('.lzo', ''))
        print 'Writing file', data_file

        with open(data_file, 'w') as f:
            f.write(response.content)
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

good news is that it did capture all of the goodies from your WWN device (Nest) tho it did not format them properly. This is why I need the files to see what's going on between my build script and the data files on your Vera. So I can adjust the script to work properly between different Vera models.

If I get this 100% working it is going to save a HUGE amount of time manually writing and maintaining these files.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

Oh and also you will no longer have a need for PLEG on the Vera or have any scenes on their handicapped scene system. Because this will generate any events that are available inside of the Vera in EG as well. YAY!!! scenes will actually run and run when they are supposed to YAY!!!! The Vera is going to simply become a bridge between EG and ZWave devices/Plugins you have running on the Vera. You will no longer have a need to use the Vera UI as you will be able to do everything from EG that the UI allows you to do. plus the things the UI doesn't allow you to do. right down to uploading lua files or if you wanted to you could create scenes and attach lua code to them. the build_vera script exposes all of those abilities.

I am going to build in a mechanism so the user is able to turn on events for specific items on different devices. This way you do not get information from changes you really do not want to know about. example would be the updating of the time the last polling cycle ran. some may want to know this. others may not.
If you like the work I have been doing then feel free to Image
holdestmade
Experienced User
Posts: 182
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade »

That is just what I'm after using vera as little as possible.

I've PMd you the ZIP

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

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

Ok I have spent some time working on this thing. I have an almost 100% working prototype. It builds the files I. Able to use the the autogenerated code functions without issue. I have to finish up the events and also check to see if setting an attribute directly works.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

HOLY COW!

OK so i fixed my Vera. But what i did was I manually went into the thing and deleted all of the dynamic bit in it. things like logs and plugin files. that kind of thing. Then i installed the newest firmware and I do have to say.. it is running a hell of a lot better then it has for a very very long while. I am guessing since the Vera doesn't remove the plugin files or clear any of the log files things of that nature this causes a severe problem with it. I do not completely understand as to why it would not delete the plugin files when you remove a plugin. But it seems most of my problems were stemming from lack of space. But you get no message stating that. it just acts all wonky. I can give instruction on how to do this. But you have to remember this process cannot be undone. and you will also have to reinstall everything. you cannot restore a backup because it will put all the crap back in.


On another note.

The API works!!!... I can set any variable on the Vera. I can also view any variable. as well as access any of the "little known" methods and also any methods that are hidden. This now supports any and all plugins/devices that exist now or will be made later. This is a huge accomplishment. I still have to go through the event end of it but the pulling of the data and the setting of variables and calling methods all work.

Now here is a nice little bonus I will be adding to it. You know all of those devices the Vera doesn't support. Or a device does not have a full API. things like TV's where you can only do very basic things like power and channel changes. because the processing power and memory of the Vera make it so that you can't have a full featured API. well that is going to go bye bye as well. I am going to code in a mechanism to extend the ability of the Vera to include the abilities of a PC. so if you can control it from a PC then you will also be able to control it from the Vera as well. If i do this right you will be able to do things like restart EG from the Vera. or maybe even have the log output of EG show up in the Vera UI.

And one cool thing is because of how I set this whole thing up this time around. it is lightning fast.
it takes 350 milliseconds to import the built Vera modules make the connection to the Vera grab all of the needed data from the Vera. build the alerts, devices, categories, plugins, ip requests, rooms, scenes, upnp devices, users, user geofences, user settings, and weather. I also threw in a command to the virtual switch plugin and told it to toggle state.

This does not include the actual creation of the files needed. That process is only done if it is a first time run of the program or if it is unable to locate a specific device type or service type. so if you install a new plugin it will rebuild the files.
If you like the work I have been doing then feel free to Image
holdestmade
Experienced User
Posts: 182
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade »

Wow certainly sounds brilliant.

Looking forward to trying it out.

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

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

I haven't made the EG plugin side of it yet. I am still thinking about how to do that. Because of the dynamic nature of it any actions would have to be made when EG starts up. I think I may have a solution but I am going to have to override some EG internals possibly to make it work right.

I am also trying to come up with a mechanism for allowing the user to specify events for specific value changes. I am almost done with coding up how the event system is going to work on the back end but it's the traversal of the various items that is going to be a little more on the difficult side.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

ok so hey... I want you to take a look at my profile picture.... I seriously look like that. see what the f'in Vera does to a person.

I believe I have gotten most of the glitches removed from the core of it. only way to know is to test it.

I set up a repository for it HERE.

I would suggest downloading and installing python 2.7. You will need to copy the micasaverde_vera folder into the Libs\site-packages folder of the installation. then you can follow the brief instructions on the main page of the repo.
If you like the work I have been doing then feel free to Image
holdestmade
Experienced User
Posts: 182
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade »

Hi,

Just tried this and got this error after: vera = Vera('192.168.1.205')

Am I missing something ?

Cheers

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
vera = Vera('192.168.1.205')
File "C:\Python27\lib\site-packages\micasaverde_vera\__init__.py", line 228, in __new__
from micasaverde_vera.core.devices import home_automation_gateway_1
ImportError: cannot import name home_automation_gateway_1
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

did it build the files?
If you like the work I have been doing then feel free to Image
holdestmade
Experienced User
Posts: 182
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade »

Hi,

It created 2 folders in 'MiCasaVerde_Vera', 'devices' and 'services'. In devices, 2 files, __init__.py (0KB and blank) and __init__.pyc (1KB) and in services, 1 file, __init__.py (0KB and blank).

It errored almost instantly after sending vera = Vera('192.168.1.205')
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

i am wondering as to why it is only building such a small number of files.


What model Vera are you running?? and what version of UI. I need the build number of the UI.. As an example I am using a Vera3 and I am using UI7 7.0.23 build 1.7.987 which is the latest available.

I have the files from your Vera. So I know it sees the files..

you can manually build the files and have it print out all kinds of data..use the code below.

Code: Select all

from micasaverde_vera import Vera

Vera.build_files('YOUR_IP_ADDRESS', log=True)

If you like the work I have been doing then feel free to Image
holdestmade
Experienced User
Posts: 182
Joined: Thu Dec 04, 2014 2:44 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by holdestmade »

Its a Vera Lite, UI7 and firmware 1.7.963, not the latest but its too full to update and will need a backup, update and restore which I have not got round to yet.

The command above also throws the same error.

Did you see my PM about personal info ?


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

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kgschlosser »

ok we are now going to try to go around this problem.

Code: Select all


from micasaverde_vera import vera_build

vera_build.build_files('YOUR IP", log=True)

If you like the work I have been doing then feel free to Image
Post Reply