Add control for a custom remote on OpenHab

Tags: #<Tag:0x00007f616ef7da10>

Hello,

I actually reverse enginereed my tv remote for my haier TV : https://github.com/Tukks/haierV300SApi
Basically, you send post and get command to switch channel and everything.

Now, I don’t understand how to add all this API to my openhab installation? do I need to develop a custom Bindings for my case?

Thank for your help

You may want to take a look at the HTTP binding. (https://www.openhab.org/v2.5/addons/bindings/http1/) From what I saw on GitHub, it looks like you are just using HTTP. I don’t have any experience using the binding or with Haier TVs though.

Regards,
Burzin

1 Like

There are many ways you can achieve this and their is now wrong way only working or not.

This is one way I achived sending requsts to a device.It uses Json not XML so would need some changes but not many.

The crux of it is sending data using curl.

curl@@-sSH@@"Accept: */*"@@-H@@"Content-Type: text/plain"@@-X@@POST@@-d@@' + CommandData + '@@' + CommandURL

You do this by Exec Action

You may need to create a map file to handle body data to make it easier to follow.

So you could do custom binding or just use a rule to send the data using curl

Thank for the response :
I did this :

 rule "Télévision item_television_power"
when
     Item item_television_power received update
then
    logWarn("television", "item_television_power");

    sendHttpPostRequest("http://192.168.1.13:56789/apps/SmartCenter", "", "<remote><key code=1012/></remote>");
end

rule "Télévision item_television_channel"
when
    Item item_television_channel received command
then

    logInfo("item_television_channel", "item_television_channel");

    logInfo("item_television_channel", item_television_channel.state.toString);

    if (item_television_channel.state.toString.length < 2) {

        sendHttpPostRequest("http://192.168.1.13:56789/apps/SmartCenter", "", "<remote><key code=100"+ item_television_channel.state.toString +"/></remote>");

    } else {

        var number = item_television_channel.state.toString.split('');

        for (var i = 0; i < number.length; i++) {

            logInfo("item_television_channel", number.get(i));

             sendHttpPostRequest("http://192.168.1.13:56789/apps/SmartCenter", "", "<remote><key code=100"+ number.get(i) +"/></remote>");

            Thread::sleep(100);

        }

                

    }   

end

and in item

Group   Television              "Télévision"                            {alexa="Endpoint.TV"}

    Switch  item_television_power   "Alim"              (Television)        {alexa="PowerController.powerState"}

    String  item_television_channel "Chaine"            (Television)        {alexa="ChannelController.channel" [TF1=1, M6=6, ARTE=7, C8=8, W9=9, TMC=10, NRJ12=12, FR4=14,  GULLI=18]}