I need to invert the value of my Chromecast idle state, so that I can add it to a group together with my PCs state from the network binding and they behave in the same way:
ON - when the device is active
OFF - when the device is in active
I know could use the proxy switch, but I thought I would try the mapping service, which unfortunately I cannot get to work. This is what I have:
I installed the mapping service in addons.cfg and saw in the logs, that it was installed:
transformation = map
In chromecast.items:
Switch Chromecast_Livingroom_Idle "Chromecast Livingroom Idle" <network> (gAssistent) { channel="chromecast:chromecast:livingroom:idling" }
Switch Chromecast_Livingroom_Active "Chromecast Livingroom Active" <network> (gAssistent) { channel="chromecast:chromecast:livingroom:idling", profile="transform:MAP", function="on_off_invert.map" }
In on_off_invert.map:
OFF=ON
ON=OFF
Any help would be much appreciated.
rossko57
(Rossko57)
March 23, 2020, 7:59pm
2
Transform profiles only work with String type Items
opened 10:41PM - 19 Jun 19 UTC
closed 11:12AM - 04 Aug 20 UTC
Profiles allow for manipulation of values in between Items and binding channels.…
Transform profiles allow user-defined manipulations e.g. numeric SCALE or arbitrary javascript JS.
Unfortunately, transform "output" is in string form.
Those bindings that support "upstream" transforms (i.e between binding and channel) allow the user to output from a JS transform into a number channel, presumably carrying out some parsing somewhere.
But when used as a profile, attempts to route transform (string) output to a Number type Item are silently rejected.
This really a restatement of [#4995](https://github.com/openhab/openhab2-addons/issues/4995) which was closed "won't fix", expanding it to include JS, and calling it an enhancement request.
It seems to me that an enhancement allowing transform profiles to feed Number and Number:UoM Items would be a useful enhancement.
For those bindings not directly supporting transforms, the uses of SCALE for e.g. sensor readings are obvious. The greater flexibility of JS would allow parsing of numeric values from text, translation of units to OH standards e.g. "99 kilowatts" to "99 | kW", and even adding units where known but not sent in the data.
Equivalent functionality to postUpdate?
Unrelated issue really, but a means of logging transform profile errors would be an advantage.
There’s little cost in creating a proxy Item and an update-invert rule
stonke
(Kristoph)
January 14, 2022, 6:10pm
3
would you share “update-invert rule” with us? have a same chromecast issue
rossko57
(Rossko57)
January 14, 2022, 7:48pm
4
This is an old thread, 2 years have passed. If you are using now OH3, you could use a profile.