Hi,
I got a ESP8266 chip with restful webservice.
Do anyone know how to get the information and use it in HomeAssistant?
It’s a long shot, I don’t have much info…
Hi,
I got a ESP8266 chip with restful webservice.
Do anyone know how to get the information and use it in HomeAssistant?
It’s a long shot, I don’t have much info…
I don’t know how to use it or what to do
I got the IP of the device.
And got this out of Postman GET:
Can I do something with it?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="icon" href="images/atom196.png">
</head>
<body>
<header class="navbar navbar-default navbar-static-top" id="top" role="banner">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">ESP8266 + FastLED</a>
</div>
</div>
</header>
<div class="container">
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-1 col-sm-offset-2">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-refresh" id="btnRefresh"></span>
</button>
</div>
<div class="col-sm-4">
<p id="status" class="form-control-static">Status</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Power</label>
<div class="col-sm-6">
<div class="btn-group" role="group" aria-label="Power">
<button type="button" class="btn btn-default" id="btnPowerOn">On</button>
<button type="button" class="btn btn-default" id="btnPowerOff">Off</button>
</div>
</div>
</div>
<div class="form-group">
<label for="inputBrightness" class="col-sm-2 control-label">Brightness</label>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="spanBrightness">128</span>
<input class="form-control" id="inputBrightness" type="range" step="1" min="0" max="255" />
</div>
</div>
</div>
<div class="form-group">
<label for="inputPattern" class="col-sm-2 control-label">Pattern</label>
<div class="col-sm-6">
<select class="form-control" id="inputPattern">
</select>
</div>
</div>
<div class="form-group">
<label for="inputPalette" class="col-sm-2 control-label">Palette</label>
<div class="col-sm-6">
<select class="form-control" id="inputPalette">
</select>
</div>
</div>
<div class="form-group">
<label for="inputColor" class="col-sm-2 control-label">Color</label>
<div class="col-sm-6">
<input id="inputColor" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-2">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF0000;" title="Red"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF8000;" title="Orange"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FFFF00;" title="Yellow"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #80FF00;" title="Chartreuse"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #00FF00;" title="Green"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #00FF80;" title="Spring Green"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #00FFFF;" title="Cyan"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #0080FF;" title="Azure"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #0000FF;" title="Blue"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #8000FF;" title="Violet"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF00FF;" title="Magenta"> </button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF0080;" title="Rose"> </button>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="js/scripts.js"></script>
</body>
</html>
That doesn’t look like a restful response… is there an endpoint you need to hit to get a rest response? That’s just returning you the webpage that must be the landing page for the ipaddress on port 80.
Thank you for your answer, I thought so.
I got this installed on my ESP8266 chip: https://github.com/Links2004/arduinoWebSockets
Where do I find the Endpoint?
Now I found this:
When i did http://myip/all in POSTMAN GET
{
"power": 1,
"brightness": 122,
"currentPattern": {
"index": 5,
"name": "Snow Glitter"
},
"currentPalette": {
"index": 2,
"name": "Cloud"
},
"solidColor": {
"r": 0,
"g": 0,
"b": 255
},
"patterns": [
"Color Waves",
"Palette Test",
"Pride",
"Rainbow",
"Rainbow With Glitter",
"Snow Glitter",
"Confetti",
"Sinelon",
"Juggle",
"BPM",
"Solid Color"
],
"palettes": [
"Rainbow",
"Rainbow Stripe",
"Cloud",
"Lava",
"Ocean",
"Forest",
"Party",
"Heat"
]
This is the code I flashed my ESP8266:
Is it possible to do something about it?
See all patterns and change patterns in HA?
It looks like there are endpoints for:
/all
/power
/solidColor
/pattern
/patternUp
/patternDown
/brightness
/brightnessUp
/brightnessDown
/palette
Take a look at: https://home-assistant.io/components/switch.rest/ for the configuration for a restful switch to ie turn a light on and off.
There is no restful light component in Home Assistant, but you may be able to achieve some control over some of the variables by combining multiple switches in a Template Light: https://home-assistant.io/components/light.template/.
Thank you, but im so novice about this. I don’t know what command I should use…
Ok try this. In your configuration.yaml, under switch:
add:
switch:
- platform: rest
name: Rest Test
resource: http://youripaddress/power
body_on: "1"
body_off: "0"
is_on_template: '{{value_json.power == body_on}}'
Change youripaddress to the ip of the ESP. Restart Home Assistant. If you are not using a default view, you should now have a switch called Rest Test in your frontend. Try flipping it. Does the LED turn on and off?
Yesyesyes, that works!!
EDIT: It works to turn off, not to turn on…
I’ve added something to the code I posted above, try that.
Now I can’t turn off it or turn on it. The switch just pop back to on after I click it.
switch:
- platform: rest
name: Rest Test
resource: http://10.10.10.10/power
body_on: "1"
body_off: "0"
is_on_template: '{{value_json.power == body_on}}'
From what I can see in the code, it looks like the parameters are arguments, rather than in the body of the message?
What does that mean, for a noob like me?
It will mean nothing to you. But I specifically replied to @marthocoo to indicate that it wouldn’t. He may see that his current approach won’t work, or he may correct me.
You’re right. That’s what I get for not looking at the code before posting and just assuming. I’m not sure how to easily acheive this, then.
I think you need to use the Restful command component.
Do you have an example I can start with?
I don’t know of one. You are breaking new ground here. But it should be possible.