Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable types missing (V_VAR1...) and why readOnly="true" #8

Closed
gnalbandian opened this issue Mar 11, 2016 · 12 comments

Comments

Projects
None yet
4 participants
@gnalbandian
Copy link

commented Mar 11, 2016

Hello.

I am dealing with a sensor that requests a numeric value from OH2. Unfortunatelly, the only item type I can use to link the channel from where the node makes its request, is a dimmer type because all the other variables are read only.

 <channel-type id="temp-channel">
        <item-type>Number</item-type>
        <label>Temperature</label>
        <description>MySensors Temperature Channel</description>
        <category>Temperature</category>
        <state pattern="%.1f °C" readOnly="true"></state>
    </channel-type>

Is there any reason for this? Why wouldn't be possible for a node to ask for a temperature for example?
I have found that when I set the type as temperature or other numeric tipe variables, the payload sent out has '0' where it should have the desired value.

Another thing I noticed, is the lack of variables V_VAR1, V_VAR2...that are defined at MySensors variable types. Is there any reason to avoid this type of variables.

Once again, I appreciate very much the effort you have put in this binding. It really works greats.
Hope we can add the mentioned features.
Regards.
Gonzalo

@gnalbandian

This comment has been minimized.

Copy link
Author

commented Mar 22, 2016

Shouldn't we add this lines to MySensorsBindingConstans.java?

public final static String CHANNEL_VAR1 = "v_var1";
public final static String CHANNEL_VAR2 = "v_var2";
public final static String CHANNEL_VAR3 = "v_var3";
public final static String CHANNEL_VAR4 = "v_var4";
public final static String CHANNEL_VAR5 = "v_var5";         

put(MYSENSORS_SUBTYPE_V_VAR1, CHANNEL_VAR1);
put(MYSENSORS_SUBTYPE_V_VAR2, CHANNEL_VAR2);
put(MYSENSORS_SUBTYPE_V_VAR3, CHANNEL_VAR3);
put(MYSENSORS_SUBTYPE_V_VAR4, CHANNEL_VAR4);
put(MYSENSORS_SUBTYPE_V_VAR5, CHANNEL_VAR5);

I am not sure how the ThingTypeUID definition would be for these cases.
Thanks, regards.

@tobof

This comment has been minimized.

Copy link
Owner

commented Mar 22, 2016

Adding the variables V_VAR1, V_VAR2 ... is no problem!

Currently it is not possible to answer an request send to the OH2 binding due to a limitation of the API. I'm not able to get the value of an item.

Here is the answer of the core developer:
https://groups.google.com/forum/#!topic/openhab2/QbmaSwC59l0

So we need to save the value by ourself, which is harder as it sounds, as all items are handled by the same handler and the handler handles all types of data (decimal, string, percentage ...).

@gnalbandian

This comment has been minimized.

Copy link
Author

commented Mar 22, 2016

Thanks for the answer TimO. No luck for now then.
Regards.

@DenkeDenke

This comment has been minimized.

Copy link

commented Mar 22, 2016

Made a pull request just now for HVAC device, where i added the V_VAR1 to V_VAR5 as i needed them for my Thermostat

@tobof

This comment has been minimized.

Copy link
Owner

commented Mar 23, 2016

@gnalbandian Could you provide an example?

  1. How does the request look?
  2. What answer do you expect?

It is easier for me to implement if I have a example to test with.

@gnalbandian

This comment has been minimized.

Copy link
Author

commented Mar 23, 2016

Hi TimO.
I have implement a heartbeat message for my nodes, so as to see (over time) is they are alive or they had died due to battery drain or whatever.

This heartbeat or beacon, is send to the gateway every couple of minutes. This interval is defined by a Setpoint item in OpenHAB and requested by the nodes everytime they boot up. I called that interval "Heart Rate"

msg[HeartRate].setType(V_VAR1);
gw.request(msg[HeartRate].sensor,msg[HeartRate].type);

So, what I need, is the binding to detect this request and trigger a rule in OH2 such as the following:

rule "Heart Rate request"
when
    Item HeartRate received command
then
if (receivedCommand == "REQUEST")
{
    logInfo( "Heart Rate", "Heart Rate request")
    sendCommand(HeartRate, (Heart_Rate_Setpoint.state as DecimalType).intValue));
}
end

Let me know if you need some extra details.
I have this feature working fine, but without the ability to request the heart rate value at boot up.
What I do, is everytime I manually change the Heart rate with OH2 setpoint, I send to all the nodes the new value.

Regards!

@tobof

This comment has been minimized.

Copy link
Owner

commented Mar 24, 2016

To speak in SerialAPI should it look like this?

Node sends a request for V_VAR_1 like:
0;0;2;0;24;

OH should respond with:
105;2;1;0;24;1000
(where 1000 is the value of the item)

I currently don't have a hardware node that sends requests so I will teach my MockGateway.

@gnalbandian

This comment has been minimized.

Copy link
Author

commented Mar 28, 2016

mmm not quiet right.

Suppose our node has id=1, heartbeat sensor id=252, with variable type V_VAR1.
The serial message request received at the gateway would look like this:

1;252;2;0;24;

And the answer from the controller would look like this:

1;252;1;0;24;1000

Let me know if there is anyway in which I can help you.
Regards.

@tobof

This comment has been minimized.

Copy link
Owner

commented Mar 29, 2016

Thanks for the heads up. So the debug output of the implementation looks like this:

2016-03-29 12:51:02.553 [DEBUG] [o.b.m.protocol.MySensorsReader:51   ] - 1;252;2;0;24;
2016-03-29 12:51:02.554 [DEBUG] [o.b.m.handler.MySensorsHandler:249  ] - Reqeust received!
2016-03-29 12:51:02.554 [DEBUG] [o.b.m.protocol.MySensorsWriter:77   ] - Sending to MySensors: 1;252;1;0;24;1000
2016-03-29 12:51:02.557 [INFO ] [smarthome.event.ItemStateEvent:43   ] - thermo01 updated to 1000

This is what you need?

@gnalbandian

This comment has been minimized.

Copy link
Author

commented Mar 29, 2016

Exactly. Thanks TimO. Looking forward to test this.
Just a litle spelling correction. "Request received!"

Regards!

@glmnet

This comment has been minimized.

Copy link

commented Jul 23, 2016

Shouldn't this be closed? I'm successfully updating sensors using VAR_1 and got here because I had another unrelated issue. (Nb: Using postUpdate instead of sendCommand)
Got biased this was my issue.

@tobof

This comment has been minimized.

Copy link
Owner

commented Jul 25, 2016

Yes @glmnet , I suppose it is working as requested! :)

@tobof tobof closed this Jul 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.