Restful switch not appearing in UI

I have created a new restful switch in my configuration file as follows:

  • platform: rest
    body_on: ‘{“room”:“Work room”, “temp”: 23, “damper”: “high”}’
    body_off: ‘{“room”:“Work room”, “temp”: 23, “damper”: “off”}’
    name: Work room AC

After reloading/restarting homeassistant, nothing happens and I dont see errors in the log file, but also no new switch appears in the UI.

Any thoughts on this?

Shouldn’t you be using your non-routable internal ip address instead of an external ip address?

Well, I know its against RFC, and not one of those known to be private ip addresses, but its very short ot use and sometimes i use mobile so 1.1.1.x is always fastest to write :slight_smile:

This is the internal IP. my router is configured to subnet

You may want to change to either the -, - or - . subnets, as the ip addresses you are using are probably assigned to other users of the same isp. In other words may be in use by your neighbour, or someone down the street. You are trying to access a computer that you don’t own.

What I do is alias ip addresses to names in my /etc/host file eg:

cat /etc/hosts	localhost	alexis	     haven	     likely	     willy	 skynet	 raspberrypi	 hass

I don’t have anything running windows at the moment, but editing the hosts file in Windows works the same way, and if I remember correctly OSX has an /etc/hosts file.

I then access HA by typing http://haven:8123 :slight_smile:

For remote access I use Duckdns

I agree, but thats a general note (which I very much appreciate).
I will probably change that some other day, since its a mini operation :slight_smile:
Meanwhile, its not really an issue, since it does the routing OK and so the only question left is why the switch doesn’t appear in the UI. Any thoughts on that one?

Could be several things, do you have a separate switches.yaml, if not can you just post the switches section of you configuration .yaml. Highlight the text when you paste it into your reply then click the </> icon so that the section is formatted properly, so that we can check the formatting.

I dont have any.
I took the restful switch example and posted it as-is, that is not enough?
I was under the impression it is (after configuring other stuff like google assistant and vera)

Do I need to take care of templating and other stuff as well?
I thought there is an easy way to make just a toggle button?

  - platform: rest
    body_on: '{"room":"Work room", "temp": 23, "damper": "high"}'
    body_off: '{"room":"Work room", "temp": 23, "damper": "off"}'
    name: Work room AC

Im still stuck, Will be very happy for some instructions on that matter

Wouldn’t it be easier with a command line switch and curl?

Yes, this can be a nice idea (not very elegant) but should can work! :thinking:

Is there a complete example to get me up in speed, and understand how it all works together?
Since I wrote the server which Im trying to communicate with, is there a preferred format for the API in order to get the state and the temperature readings?

Depending on how your server respond on webhooks.
In my case for request the temperature of my IoT, I must place a HTTP request like following; at my blynk server.
My server at the following webhook:

… answer with (eg.):


… so in your config you must use some like this…

  - platform: rest
    verify_ssl: false
    name: T2
    scan_interval: 60
    value_template: >-
      {{ value | replace('"','') | replace("[","") | replace("]","") | float }}
    unit_of_measurement: °C

Shouldn’t it be platform arest, not rest?

Im not not sure why.
Also, this is a regular nodejs http server, so rest platform suffice IMO.
my switch now appears in the UI, but the problem is that for some very odd reason, when using the ip, which is the correct one to use and is where my nodejs server resides, I get the error:

Can’t turn on Is resource/endpoint offline?

But If I open up some webserver on my laptop, at in that matter…it works fine!
So what is going on with this switch logic?

This is the updated version of my switch config:
- platform: rest
name: Guest room A/C
body_on: ‘{“damper”:“high”, “temp”:24, “room”:“work room”}’
body_off: ‘{“damper”:“off”, “room”: “work room”}’
is_on_template: ‘{{value_json.damper == “high”}}’

… maybe a firewall / security issue?

Try to use curl and specify the -k option to bypass some certification problem.

p.s.: please use the preformatted text option when post your code in way that we can see if the indentation is correct.

no, and i tried plain http
the only way i got it using port forwarding and accessing it using external IP