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.
Post Reply
Sulliv@n
Posts: 12
Joined: Fri Apr 03, 2015 9:37 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by Sulliv@n »

Looking and sound good! Especially the get state command, I would love that.
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 »

this will be the last i probably do any development with the Vera because it's so horribly problematic I am going to change to something different in the very near future. and I am not going to be running the device anymore to be able to test the functionality of things i do.. so I am trying to make it as dynamic as possible so it can change as the people at MIOS change things in their software. i do not know how successful i will be with it. or how long it will run for. but they like to change things about all the time and not tell anyone of the change and just let anyone who programmed something for it deal with their own support problems. I hate it when a company doesn't care about the people who make addons for their software. considering it's those people that are making it better.
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 »

i did want to give you an update. from further investigation i can request the data from the vera as xml or as json... this i know already... what i didn't know is that the vera stores the data natively as json and has to do a conversion to xml and being that the data is some 12 thousand lines on my vera and i have 50 devices and 4 plugins. this is got to be one hell of a performance hit for the vera. so what i did was i rewrote the receiving end of the plugin to use json and then i had to write something up to convert from json to xml. because the converters that already existed didn't format the data exactly the same as how the vera has it and they were horribly slow as well... almost a 1/2 to 1 second to do the conversion.... code i wrote gets it done in about 15 milliseconds. and trust you me I now know more about xml and json conversion then i really thought i would have to know.. LOL and i also coded in a means to dump the raw output to a file..
If you like the work I have been doing then feel free to Image
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

I'm having trouble parsing events due to a decimal payload or suffix. An example of an event I would like to use:

Code: Select all

MCV.Weather.Temperature.Temperature Sensor.Temperature.69.0 {'key3': 'Temperature', 'key2': 'Weather', 'key1': u'MCV', 'value': {'category': 'Temperature Sensor', 'subcategory': 0, 'parent': 176, 'altid': 'Weather-Current-Temperature', 'catID': 17, 'name': 'Temperature', 'temperature': '69.0', 'roomID': 10, 'id': 177, 'room': 'Weather'}}
I thought that I could use this type of event every time the Temperature was reported. I would have thought that a wildcard like this would work, MCV.Weather.Temperature.Temperature Sensor.Temperature.*

Unfortunately, it doesn't, and I think the culprit is the decimal result (e.g. 69.0). According to the definitive post on this topic by Pako, a wildcard can only be used in the second position (e.g. MCV.*) or the final position, so that would be MCV.Weather.Temperature.Temperature Sensor.Temperature.69.*

That makes it pretty difficult to match. The only solution I can think of is to parse all MCV.* events, but that is a huge number of events that EG would have to individually process.

Any bright ideas about how to approach this? Thanks.
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 »

for EG version 0.4 it should work on every other event "section"

MCV.Weather.Temperature.Temperature Sensor.Temperature.69.0

MCV.*
MCV.Weather.Temperature.*
MCV.Weather.Temperature.Temperature Sensor.Temperature.*

but there may be a limit to how far out it will go... so you may only be able to do
MCV.Weather.Temperature.*

I am honestly not sure as i have not looked at the code for the event triggering to see how it functions.

but with version 0.5beta the wildcard system works differently and I have not played around with it at all and know not a thing about it...

I will take a look and see what i can find out.. give me a few hours I have something i need to attend to first
If you like the work I have been doing then feel free to Image
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

kgschlosser wrote:for EG version 0.4 it should work on every other event "section"
I hope that's true, but it doesn't seem to work for me. Using 0.4.1.r1722. Perhaps you incorporated blackwind's Support wildcard patterns in event bindings? I might have to try that if it works.
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 »

no i am talking about under the old method. but i have to look t the code and see how far into the event it will allow the wildcard

for some reason i think it's only 2 tiers of every other. which would mean after the 3rd . and that's it. i remember going through this myself for my own use. i'm going to go and look now. and if you don't object to modifying the core code i can send you a change that will make it work for you. otherwise i will have to build in an override of the trigger event for the plugin and i really don't want to have to do that..


the new version i am working on is going to be really cool. in the fact that you will be able to set a listener to a specific device. meaning that if any variable changes. not just the ones that are in the events. it will call the listener you provided and pass the variable name that changed. what the old value was and what the new value is. the purpose for this is to expose all of the data in a device but also being able to act upon a change that takes place..

I am also coding in for the plugin to build a dictionary in the language that the user has specified for EG or the language that the vera is set to or to override it completely and set whatever you want. and this will also do realtime translation for all the events as well. support for 70 languages. and it will build the dictionary as the events come up. this will only work if you have an internet connection. but if you have a vera you are kind of forced to have one. which annoys the crap outta me and is one of the biggest reasons why i am going to dump this controller and build my own.

i'mma go and look at the trigger event code. i'll let you know what i found
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 it is only 2 tiers well actually 3. the first the second and the last. but i don't know why someone would put just a * to capture all events

i was wrong in the order of things.. so the second and the last

I have not tested the code below. but if you have a problem add a # before the lines that were added and remove the # from the original lines

this will make it so that every tier in an event can be wild carded

change the code in EventGhost\eg\Classes\EventGhostEvent.py file from this

Code: Select all

    def Execute(self):
        #start = clock()
        eventString = self.string
        if eventString in eg.notificationHandlers:
            for listener in eg.notificationHandlers[eventString].listeners:
                if listener(self) == True:
                    return

        eg.event = self
        eg.eventString = eventString
        eg.EventString = eventString # eg.EventString is deprecated

        get = eg.eventTable.get
        eventHandlerList = []
        eventHandlerList += get(eventString, [])
        #if self.prefix != "Keyboard":
        eventHandlerList += get(self.suffix, [])
        key2 = self.suffix.rsplit(".", 1)[-1]
        if self.suffix != key2:
            eventHandlerList += get(key2, [])
        eventHandlerList += get('*', [])

        key1 = eventString.rsplit(".", 1)[0] + '.*'
        eventHandlerList += get(key1, [])
        key2 = eventString.split(".", 1)[0] + '.*'
        if key1 != key2:
            eventHandlerList += get(key2, [])

        activeHandlers = set()
        for eventHandler in eventHandlerList:
            obj = eventHandler
            while obj:
                if not obj.isEnabled:
                    break
                obj = obj.parent
            else:
                activeHandlers.add(eventHandler)

        for listener in eg.log.eventListeners:
            listener.LogEvent(self)

        if config.onlyLogAssigned and len(activeHandlers) == 0:
            self.SetStarted()
            return

        # show the event in the logger
        LogEvent(self)

        activeHandlers = sorted(activeHandlers, key=GetItemPath)

        eg.SetProcessingState(2, self)
        for eventHandler in activeHandlers:
            try:
                eg.programCounter = (eventHandler.parent, None)
                eg.indent = 1
                RunProgram()
            except:
                eg.PrintTraceback()
            if self.skipEvent:
                break
        self.SetStarted()
        eg.SetProcessingState(1, self)
to this

Code: Select all

    def Execute(self):
        # start = clock()
        eventString = self.string
        if eventString in eg.notificationHandlers:
            for listener in eg.notificationHandlers[eventString].listeners:
                if listener(self) == True:
                    return

        eg.event = self
        eg.eventString = eventString
        eg.EventString = eventString # eg.EventString is deprecated

        get = eg.eventTable.get
        eventHandlerList = []
        eventHandlerList += get(eventString, [])
        # if self.prefix != "Keyboard":
        eventHandlerList += get(self.suffix, [])
        key2 = self.suffix.rsplit(".", 1)[-1]
        if self.suffix != key2:
            eventHandlerList += get(key2, [])
        # eventHandlerList += get('*', [])

        # key1 = eventString.rsplit(".", 1)[0] + '.*'
        # eventHandlerList += get(key1, [])
        # key2 = eventString.split(".", 1)[0] + '.*'
        # if key1 != key2:
        #     eventHandlerList += get(key2, [])

        eventList = eventString.split('.')
        foundEvents = []
        while eventList:
            eventList[len(eventList) - 1] = '*'
            foundMacro = get('.'.join(eventList), False)
            if foundMacro:
                foundEvents.append(foundMacro)
            eventList.pop()

        eventHandlerList.extend(sorted(foundEvents, reverse=True))

        activeHandlers = set()
        for eventHandler in eventHandlerList:
            obj = eventHandler
            while obj:
                if not obj.isEnabled:
                    break
                obj = obj.parent
            else:
                activeHandlers.add(eventHandler)

        for listener in eg.log.eventListeners:
            listener.LogEvent(self)

        if config.onlyLogAssigned and len(activeHandlers) == 0:
            self.SetStarted()
            return

        # show the event in the logger
        LogEvent(self)

        activeHandlers = sorted(activeHandlers, key=GetItemPath)

        eg.SetProcessingState(2, self)
        for eventHandler in activeHandlers:
            try:
                eg.programCounter = (eventHandler.parent, None)
                eg.indent = 1
                RunProgram()
            except:
                eg.PrintTraceback()
            if self.skipEvent:
                break
        self.SetStarted()
        eg.SetProcessingState(1, self)

If you like the work I have been doing then feel free to Image
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

I really appreciate your help. I'm having trouble with the replacement code; EG won't load after making the changes. No error messages. Just doesn't start. The only thing I notice after pasting in the new code is that there is an extra level of indentation. I tried to manually remove the extra lading spaces, and also tried just entering the stuff that changed, but that just got me a bunch of red error messages.

Procedure:
Exit EG
Delete EventGhostEvent.pyc
Make changes to EventGhostEvent.py
Restart EG
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 let me do this. i will attach the eventghostevent file that way it will be indented correctly
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 i have tested this bad larry. and it works, redid the code and simplified it a lot.

it is attached

K
Attachments
EventGhostEvent.py
(6 KiB) Downloaded 107 times
If you like the work I have been doing then feel free to Image
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

Worked like a charm! Thanks so much for your help.
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 »

no worries...

I'm happy to lend a hand.

i had done a similar modification to my "server" version of EG i I forgot that i did it. i did it almost a year and a half ago. it's fun to go back and look at code from when i was starting out.... it took 30 lines back then what i did in 2 this time.. LOL

and it is faster this way as well...

tooo funny...
If you like the work I have been doing then feel free to Image
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

Your modification really increases the functionality of EG. Hopefully it can be incorporated into a future build.
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: MiCasaVerde Vera UI5, UI6, UI7 Plugin

Post by kkl »

As is typical, one problem solved, new problem arises. I finally got around to installing the current version. When I open the HVAC Control configuration, I get a stream of errors in the log. See screenshot. It appears that the data is updating in the Weather section of the configuration screen as this is happening.
Capture.JPG
2nd question: Is "My Home" hardcoded, or is the name definable somewhere?

Thanks.
Post Reply