How to output status string from rule?

I have a binding installed (Gardena) that outputs the status as text from the sitemap:

String    Gardena_Sileno_City__Status           "Status [%s]"              <lawnmower>
            Text item=Gardena_Sileno_City__Status         

The shown text is “Mähen”, “Suche Ladestation”, “Geparkt nach Zeitplan” and so on.
But when I output the status from a rule like

logInfo("Maeher", String::format("%s - %s changed to %s", triggeringItem.name, triggeringItem.label, Gardena_Sileno_City__Status.state.toString))

I only get “ok_cutting”, “ok_searching”, “parked_timer”.
In the sourcecode of the Gardena binding (Link), I found the definitions

channel-type.gardena.status.label=Mäherstatus
channel-type.gardena.status.description=Der Status des Mähers
channel-type.gardena.status.state.option.paused=Pausiert
channel-type.gardena.status.state.option.ok_cutting=Mähen
channel-type.gardena.status.state.option.ok_searching=Suche Ladestation
channel-type.gardena.status.state.option.ok_charging=Lädt
channel-type.gardena.status.state.option.ok_leaving=Mähen
channel-type.gardena.status.state.option.wait_updating=Wird aktualisiert ...
channel-type.gardena.status.state.option.wait_power_up=Wird eingeschaltet ...
channel-type.gardena.status.state.option.parked_timer=Geparkt nach Zeitplan
channel-type.gardena.status.state.option.parked_park_selected=Geparkt
channel-type.gardena.status.state.option.off_disabled=Der Mäher ist ausgeschaltet
channel-type.gardena.status.state.option.off_hatch_open=Deaktiviert. Abdeckung ist offen oder PIN-Code erforderlich
channel-type.gardena.status.state.option.unknown=Unbekannter Status
channel-type.gardena.status.state.option.error=Fehler
channel-type.gardena.status.state.option.error_at_power_up=Neustart ...
channel-type.gardena.status.state.option.off_hatch_closed=Deaktiviert. Manueller Start erforderlich
channel-type.gardena.status.state.option.ok_cutting_timer_overridden=Manuelles Mähen
channel-type.gardena.status.state.option.parked_autotimer=Geparkt durch SensorControl
channel-type.gardena.status.state.option.parked_daily_limit_reached=Abgeschlossen
channel-type.gardena.status.state.option.undefined=Undefiniert

So how can I get / output this “real” text, not only the status.option identifier?

I see only one way to accomplish this… Use a MAP transformation
Create a file called GARDENA.MAP:

paused=Pausiert
ok_cutting=Mähen
ok_searching=Suche Ladestation
ok_charging=Lädt
ok_leaving=Mähen
wait_updating=Wird aktualisiert ...
wait_power_up=Wird eingeschaltet ...
parked_timer=Geparkt nach Zeitplan
parked_park_selected=Geparkt
off_disabled=Der Mäher ist ausgeschaltet
off_hatch_open=Deaktiviert. Abdeckung ist offen oder PIN-Code erforderlich
unknown=Unbekannter Status
error=Fehler
error_at_power_up=Neustart ...
off_hatch_closed=Deaktiviert. Manueller Start erforderlich
ok_cutting_timer_overridden=Manuelles Mähen
parked_autotimer=Geparkt durch SensorControl
parked_daily_limit_reached=Abgeschlossen
undefined=Undefiniert

and use the following in your rule:

logInfo("Maeher", String::format("%s - %s changed to %s", triggeringItem.name, triggeringItem.label, transform("MAP","GARDENA.MAP",Gardena_Sileno_City__Status.state.toString)))
1 Like

Great idea - I will try it.
The only disadvantage is that the strings are doubled then - in the binding AND in the map transformation.
I thought there might be a more elegant way to get the real strings directly from the binding…