Put Thing Status in an Item

Hello,
i using some smoke detectors and want to show thing status of each smoke detector in habpanel. (show online/offline state of device)
There are a trigger to get the thing status and use a thing to display the actual thing state?

Regards, Webfeger

Take a look at this thread/example. It should hopefully get you going in the right direction…

Thanks!! that’s what i‘m looking for

I used the code but i get error messages in logfiles.

Thats the code:

 rule "CheckSmokeDetectors"

 when
 Time cron "*/5 * * * * ?" //Run this rule every 5 minutes
then
// try it with a var:
var result = ThingAction.getThingStatusInfo("mihome:smoke:158d0001xxxxxx").getStatus() 
postUpdate(WZSmokeDetector_ThingStatus,result)

// try it directly: 
WZSmokeDetector_ThingStatus = ThingAction.getThingStatusInfo("mihome:smoke:158d0001xxxxxx").getStatus()

end

and the result:

directly:

2018-08-06 20:30:05.218 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'CheckSmokeDetectors': An error occurred during the script execution: Cannot assign a value in null context.

with a variable:


2018-08-06 20:34:05.089 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'CheckSmokeDetectors': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null

Here are the working thing example:

Switch WZSmokeDetector_Alarmihome 	"Feueralarm  [%s]"			<fire>			(Wohnzimmer)		{ channel="mihome:smoke:158d0001xxxxxx:alarm" }

I solve this issue with string conversion and using result variable:

 postUpdate(WZSmokeDetector_ThingStatus,result.toString() )
1 Like

Thanks! I just setup and it works great!!