Switching Circles by MAC address
Switching Circles by MAC address
For all the Plugwise DIY-ers over here: after re-installing the Source, i rapidly changed the way i switched the Circles; not by id, but by MAC-address. I changed the cc.html a bit.
You can find it here.
You can find it here.
Switching Circles by MAC address
Thanks,
I will use this in my plugin also. I already used the MAC to lookup the Id, so a changed Id would be related to the right MAC, but this makes it easier.
Rene.
I will use this in my plugin also. I already used the MAC to lookup the Id, so a changed Id would be related to the right MAC, but this makes it easier.
Rene.
Switching Circles by MAC address
Robert
Do I see a downside that you have to loop through all the devices again to see if it is the right MAC?
Do I see a downside that you have to loop through all the devices again to see if it is the right MAC?
Switching Circles by MAC address
That's 50% right. The break stops the loop. I couldn't find another way to address the right Circle more directly. Although i gave up on that after half an hour, so maybe there is 

Switching Circles by MAC address
I take the ID, it's unique as well, and faster if you have more devices.
See below and you can switch directly without the extra loop.
The command should now be http://xxx.xxx.xxx.xxx:8080/cc.html?modid=12&cmd=on
See below and you can switch directly without the extra loop.
Code: Select all
<%
format 'Module.PowerUsage' as '{0:0.00}'
%>
<items type="array">
<% foreach Plugwise.modules %>
<item>
<id><%=.id%></id>
<datetime><%=system.date%> <%=system.time%></datetime>
<Mac><%=.MacAddress%></Mac>
<powerusage><%=.PowerUsage%></powerusage>
<Status><%=.Status%></Status>
<type><%=.type%></type>
</item>
<% /foreach %>
</items>
Switching Circles by MAC address
The ID is created by the source software and is not stored within the plug itself, correct? It looks like the ID is just a sequence number that gets incremented for each plug that is detected by the Source for the first time. This means that the ID can change overtime, for instance because you reinstall the Source software. In my plugin I keep both the MAC and the ID and when I detect the ID has been changed for a specific MAC I update the relation. This way I am almost certain I have a correct ID.
Rene.
Rene.
Switching Circles by MAC address
@Pieter: Are you sure this works? Cause this looks very much like the XML to retrieve things from the Source webserver, not the one to switch the Circles.
And i know the loop makes things slower: 0.031 vs. 0.015 seconds when looping to find the right Circle (id=12, = maximum delay in my case). But maybe in the future i have to do without a ID, when talking to the Plug directly, so i can live with the delay for now. Internally, in my own HA app, everything will stay the same in the future.
And i know the loop makes things slower: 0.031 vs. 0.015 seconds when looping to find the right Circle (id=12, = maximum delay in my case). But maybe in the future i have to do without a ID, when talking to the Plug directly, so i can live with the delay for now. Internally, in my own HA app, everything will stay the same in the future.
Switching Circles by MAC address
Let me check again in the topic somewhere.
Yes there are two ID's, check the manual.
The Appliance object has a ID which can change whit a reinstall or something.
The Module Object has an ID and a MACaddress, check this one, I think this is unique as well and comes from the module, but I'm not sure because the sequence is to neat!
And if you have to use the source software this code will always be the right idetifier.
I think you now queurie the Source software every minut for status and you get the ID on which you can Switch On and Off directly without the loop.
If we program our own driver the MacAddress will be better.
Yes there are two ID's, check the manual.
The Appliance object has a ID which can change whit a reinstall or something.
The Module Object has an ID and a MACaddress, check this one, I think this is unique as well and comes from the module, but I'm not sure because the sequence is to neat!
And if you have to use the source software this code will always be the right idetifier.
I think you now queurie the Source software every minut for status and you get the ID on which you can Switch On and Off directly without the loop.
If we program our own driver the MacAddress will be better.
Switching Circles by MAC address
I've done some 'research' an hour ago.
There is a Modules table in the Source database that has a Auto-increment field called ID. That field contains the ModuleID.
There is an Appliance table in the Source database that has a Auto-increment field called ID. That field contains the ApplianceID.
So i don't think the ID's are 'stable'. However, since i reinstalled the Source once and still have both databases (the 2nd time was a clean install, no restore of database etc.), i had the chance to have a look at both: what strikes me is that the Modules have the same ID in both versions of the databases. So the modules were inserted into the table in the same sequence. No coincidence, but what?
There is a Modules table in the Source database that has a Auto-increment field called ID. That field contains the ModuleID.
There is an Appliance table in the Source database that has a Auto-increment field called ID. That field contains the ApplianceID.
So i don't think the ID's are 'stable'. However, since i reinstalled the Source once and still have both databases (the 2nd time was a clean install, no restore of database etc.), i had the chance to have a look at both: what strikes me is that the Modules have the same ID in both versions of the databases. So the modules were inserted into the table in the same sequence. No coincidence, but what?
Switching Circles by MAC address
I'm still not confident myself, I have the same findings.
But again you query the software for example every 1 minute to get the reading, then you are sure you have the latest module.ID.
In this case you can switch directly on ID and you are sure it is the right one.
Don't get me wrong, I prefer the mac-address as well, but it is costing me in this case an extra Do while for 30 devices and delivering me the same result!
But again you query the software for example every 1 minute to get the reading, then you are sure you have the latest module.ID.
In this case you can switch directly on ID and you are sure it is the right one.
Don't get me wrong, I prefer the mac-address as well, but it is costing me in this case an extra Do while for 30 devices and delivering me the same result!
-
- Starting Member
- Posts: 30
- Joined: Thu Nov 05, 2009 8:48 pm
- Location: Luxembourg
- Contact:
Switching Circles by MAC address
Is there a possibility to see only 1 plug and schwith that one ? so not the whole list but only 1 ( maybe by typing its name? or id ? )