smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
121 stars 92 forks source link

Subscribed item properties should be updated on the websocket #661

Open wvhn opened 2 months ago

wvhn commented 2 months ago

SmarthomeNG supports subscribing item properties like e.g. myitem.property.last_change by a frontend via the monitor command on the websocket. The actual value of the item property is then sent with all regular items in the first answer. But while shNG later sends updates for the subscribed regular items, it does not send updates for item properties.

shNG should also send updates for the subscribed item properties, i.e. if an item is updated, check whether a property of that item has been subscribed and then update that, too.

msinn commented 2 months ago

That won't happen anytime soon. Properties of an Item are just that. All the methods of an item that enable SmartHomeNG to send updates for the item value do not exist for the properties. To implement updates for the 38 properties of an item would be almost a rewrite of the item class (one of the most complex classes of SmartHomeNG).

wvhn commented 2 months ago

Okay that is your decision. Please mark the issue as a bug since the current behavior is unexpected.

msinn commented 2 months ago

I just do not have the time to do a complete overhaul of one of the core components of SmartHomeNG.

The ability to get the property data was a request from a user (or users) of smartVISU. At that time monitoring the property data was not requested. As a quick fix, I added the property data.

I don't think it is a bug. I would rather remove the properties from the smartvisu protocol than declaring it a non fixable bug.

Btw.: There is a way/workaround. You just have to declare a helper item in SmartHomeNG and write the wanted property value to that helper item (in an on_change Attribute of the original item), Now you cat monitor the helper Item and get updated property information.

msinn commented 2 months ago

An addendum to my previous post:

There are three kinds of item properties.

msinn commented 2 months ago

@bmxp What do you think about it.

I just found out, you added the properties (to the visu_websocket plugin, back then). I know, it was 5 years ago and noone thought about changing properties back then.

bmxp commented 2 months ago

Something to the background of this ancient invention:

I had some Items where I wanted to get the last change, like the datetime the door was locked and I did not saw the need to implement another Item to reflect just this. Maybe it was before the elaborated struct possibilities we have today. That time it was sufficient to just refresh the SmartVisu page to see if there was something new.

SmartHomeNG became more and more documented but also complicated for the non programmer. We need to pay attention that it stays easy for most users.

So this is really not a bug but a feature that could be solved using another item maybe with a struct.

onkelandy commented 2 months ago

Actually I think most of the relevant properties can be written in a helper item by using on_update or on_change. If the respective Item has an eval expression it might be useful to also have an on_trigger option..?

wvhn commented 2 months ago

I think there is a certain demand for the function. Approx. 2 years back I have even been asked to implement a template checker routine for the item properties to be used instead of pure items in smartVISU. This year I've been asked to implement item properties for ioBroker. ioBroker sends a complete Object "mytem.state" where state contains properties like "lc" for last_change and others. I have mapped these to "myItem.property." in order to keep compatibility with shNG.