Wol & exec binding -> power On and Off Pc

I just checked the logs in openhab2 and it shows me this

2017-12-16 18:57:06.868 [WARN ] [ome.core.thing.internal.ThingManager] - Cannot delegate update ‘OFF’ for item ‘mpcoff’ to handler for channel ‘exec:command:micropcofft:run’, because no thing with the UID ‘exec:command:micropcofft’ could be found.

What does this exactly mean? (Never coded before so I am not sure what to do now)

check PaperUI for your mpcofft Thing, does it exist ? Is it online?

The thing is not there… But there should be, right?

I mean I have a it in my .things file in /etc/openhab2/things folder (I am using openhabian)

Thing exec:command:micropcofft [command="net rpc shutdown -I 192.168.1.255 -U user%%pass -f", interval=0, autorun=false]

Any idea why it is not shwoing up in PaperUI ?

You should find it under config -> things in PaperUI
Are you sure You have Exec2.0 Binding installed?

1 Like

Oh wow, thank you so much!

I was so sure I have installed it already but that must have been, before I resetted everything to have a clean install. Forgot to install it again.

I could have searched for days for the error. Thanks a lot!

kind regards,
salexes

I know I asked you already alot today but I would like to ask one more thing.

After Installing the exec binding again I also installed the regex binding in order for the exec command to work.

While doing so i received an error: Failed installing 'openhab-transformation-regex': Error restarting bundles

Could you maybe take a look, maybe you already know this kind of error and know an quick solution to it.

I think because of the error described above the shutdown command is still not working

Thanks it advance.

kind regards

Tried that, did not change anything. Sadly I am unable to install any transformation bindings. So that means I can not use the exec solution (Wol & exec binding -> power On and Off Pc), correct ?

What other options do I have? Or what else can I try to get it working?

Probably wait until tomorrow and try the upcoming 2.2 release…

Hey everybody and thanks a lot for this awesome binding.

I had this error message:
could not initialise pipe winreg. error was nt_status_object_name_not_found
and fixed it with this registry tweak: https://www.howtogeek.com/howto/windows-vista/enable-mapping-to-hostnamec-share-on-windows-vista/
Maybe this could help someone.
I assume security options prevent remote shutdown on Windows 10 default settings.

Furthermore I got it even working with Alexa, by

  • changing the MPCONOFF type from Number to Switch
  • added the Switchable Tag
  • and changed the cases in the rule (and sitemap) from 1 and 2 to ON and OFF

Another way to do it, requires network, wake-on-lan & exec :
Things

Thing network:pingdevice:pc [ hostname="192.168.1.3" ]
Thing exec:command:pcoff [command="net rpc shutdown -C MESSAGE -I 192.168.1.3 -U user%%pass", interval=0, autorun=false]

Items

Switch PC_ON "PC"              { wol="192.168.1.255#MAC_ADRESS" }
Switch PC_OFF "PC"             { channel="exec:command:pcoff:run" }
Switch  PC_online              { channel="network:pingdevice:pc:online" }

Sitemap

Switch item=PC_ON		      mappings=[ON="ON"] 	visibility=[PC_online==OFF]
Switch item=PC_OFF			  mappings=[ON="OFF"] 	visibility=[PC_online==ON]

Hello guys,

I am nearly new to OpenHab and tried the code SzilagyIR posted above to switch on my PC via WoL and shut it down via exec command. Everything works fine so first I want to say thx for the code! :slightly_smiling_face:

Today I wanted to control the wake and shutdown with Alexa so I added the following to the items:

Switch mpcon "PC1" ["Switchable"] { wol="192.168.0.255#D0:50:99:35:6E:BB" }
Switch mpcoff "PC2" ["Switchable"] { channel="exec:command:micropcofft:run" }
Number MPCONOFF "Micro Pc"

Everthing works fine and with the OpenCloud Binding Alexa found the two Items “PC1” and “PC2” and now I can start or shut down my PC with “Alexa switch PC1 on” or "Alexa switch PC2 on"
Don’t be confused because of the naming… It is only one PC :wink:

So maybe you see what is not very fine with this::

  1. I need two different devices to switch my PC.
  2. The naming is not so nice
  3. I always say “switch on” but thats simply not the truth when I switch it off with PC2 device.

My question:

Do you have any Idea how to configure it in a way I can use a switch item which will use WoL command for the ON-state and exec shutdown command for the Off-state?
Would be grate if I can say “Alexa turn the PC on” and “Alexa turn the PC off”

You simply have to put the tag to just the third item and make it a switch, which controls PC1 and PC2.

Switch mpcon "PC1" { wol="192.168.0.255#D0:50:99:35:6E:BB" }
Switch mpcoff "PC2"  { channel="exec:command:micropcofft:run" }
Switch MPCONOFF "Computer" [ "Switchable" ]

Now you simply tell Alexa to turn “Computer” on and off.

That’s what i get by following the “solutions”
==> /var/log/openhab2/openhab.log <==
2020-11-04 12:40:53.321 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘2’.
2020-11-04 12:40:55.810 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘1’.
2020-11-04 12:40:57.938 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘2’.
2020-11-04 12:41:36.446 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘1’.
2020-11-04 12:41:43.008 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘2’.
2020-11-04 12:41:43.170 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘2’.
2020-11-04 12:41:44.020 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at ‘items/MPCONOFF’ with an invalid status value ‘1’.

Stuff might have changed in three years. What are doing to get those logs? It looks like you’ve set up Alexa to send ‘1’ or ‘2’ instead of on/off.

I made it work, it was because the solutions provided by some of the users were not properly written:
I had to start from scratch by following the documentation pages. thanks for effort made by some users but posting things poor written or faulty codes is not a solution, otherwise is a waste of time. I have followed many articles and i saw users trying to help by providing a bit of information on post 1, some follow up solutions for post 15 and a last bit of code fixed from post 1 in post 36 … for me , as a user is a waste of time of 1 , 2 hours depending of things complexity… that’s what making me backing off from this openhab . i can see is operated by users, no developers are around for solutions or bindings… in my opinion this project looks abandoned since at least 1 year

Thank goodness you have posted your correct solution, for the benefit of others so that no-one else has such a terrible time as you did.

1 Like

Next time when you try to look cool on internet, make sure you have some good arguments and not act like an idiot. '57 is your born year then i feel sorry for you. period.

Now , let me explain you couple things that the “OP” forgot to mention about this:

  1. you need to add a policy update in windows registry and tweak some other settings
  2. you need to install and configure samba on host machine, in case if it’s a linux in order to establish a successful connection with that host machine
  3. this does not work with microsoft accounts
  4. this does not work with multiple accounts assigned to a machine

you know my friend, rossko57 nobody knows these as much as you do . maybe i dont have time to try making things works since i also have a job, a family to take care and can’t afford to spend hours on something poorly written . as for the OP, and other participants, thanks for the bits of information provided.