How to send Item a command to the channel linked to MQTT in a script

Hi all,

I’ve tried all sorts of searching and can’t figure this out. I’m trying to make a script that does, in part, send a command to a device via MQTT. It works manually in MQTT and in the user interface of OB3 via a payload of command to the url myserver/rest/items/myitem. I want to write a script that does that and its not working.

All of my thoughts go to myitem.sendCommand(command) and that just isn’t working. I think there has to be an obvious and simple solution but I’m just not finding it. I would appreciate any help or nudges in the right direction.

Why, what happens? Look in your events.log, and if you don’t see what you expect look in your openhab.log
What type of Item is involved? What type of channel have you linked it to? What is the configuration of that channel?

Thanks the logs had the answer. Seems you need to define the item when you do item.sendCommand(command) but you don’t need to do it when you do events.sendCommand(item,command). Once I defined the variable it worked.