Unfortunately I need to come back to the event-Block because if want to return anything back different from String then we need to think about it more in depth and we should not mix that up with the comparison thing above because that would it make even harder.
['newState', 'itemState'], // Change and Updated Event -> State => String or State-Type?
['previousState', 'oldItemState'], // Change and Updated Event -> State => String or State-Type?
['triggering item name', 'itemName'], // all -> String
['type', 'type']]), // all -> String
['receivedCommand', 'itemCommand'], // Command -> has attributes but hard to handle the different attributes per type => String
['channel', 'channel'], // ChannelTriggeredEvent -> has attributes but hard to handle the different attributes per type => String
Look at the comments above
State
The first two return a State-Object which in OH is basically a type. A type has several subclasses all of which have different methods. Most methods of those types should not be of any interest (like OnOff, DecimalâŠ) as the only thing you would probably want is the value anyway. HSBType does have getters for RGB but that is pretty specific. A State-Block would need to have a âfree-attributeâ name or you would have to provide the State-Type and from there it could âintelligentlyâ tell which attribute would be available as an attribute.
Note that these can be undefined in case it is CommandEvent.
So in summary at least for the time being I would not implement a Blockly-State-Block which would provide a state back but just return String and name that field âstate valueâ. Later we could provide the state as well that would feed into a block that takes that state and with choosing the expected type it would allow you to retrieve specific attributes for that block (we could also make that an individual block as it returns a different type State then)
Agreed?
Type and Name
Are just Strings. Type actually provides the âshort nameâ of the types class
Channel
is only available when the channel was triggered
This is actually a Subtype of Event which has the name attribute and a type which we already have. As the only interesting information is the channel name, I would not give back the channel object but again a String that contains the channel name only.
Agreed?
Event
event.event doesnât exist actually. We could return âevent.â in the code and something (any attribute or method) could be added as a free string but if there was anything we would need that is not covered above in any of the fields for one of the eventâs subtypes we should rather explicitly provide them as an attribute in this block here like the channel.
Agreed?
Hopefully you say âYesâ to all because then I would be able finish that topic tonight and can provide a PR by tomorrow which should not be too big for Yannick to review and merge soon (it contains some very minor fixes and additions).
PS: The comparison topic will be only tackled next year (or maybe over the winter holidays). I really want to put some major thoughts into that before doing it.