Hi can anyone tell me if HA supports HTTP GET commands. I am using a NodeMcu to control a servo. It uses http commands to open/close my blinds like http://192.168.0.20/blind/open. Anyway I can add it as a switch on HA? Thanks!
Look at Command Line Switch Component
Send command line Post requests or create some script that takes (on/off) as input and returns state
Thanks I am a bit of a noob to this and need some direction I have tried the rest switch method and it doesn’t work. when I type in terminal curl http://192.168.0.20/open it works I even created a open.sh and close.sh script and both work but how do I get this to work in HA? I have tried the command line switch like this:
switch:
platform: command_line
switches:
Blinds:
command_on: "curl http://192.168.0.20/open"
command_off: "curl http://192.168.0.20/close"
Home assistant doesn’t start.
For my command_line switch I am using the full path to the file.
command_on: "/home/pi/.homeassistant/./mfictrl 192.168.X.X ON"
For my rest sensor I am doing this…
- platform: rest
resource: http://192.168.X.X:1706/data_request?id=variableget&DeviceNum=20&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=Watts
method: GET
name: Power Line Watts
Is a port required?
@ptp not trying to hijack this threath but interested in what you are doing. I also have a Vera. What does you above command do? Does it pull the power line watts from this vera device into HASS? How do you then display this information in HASS?
That is correct, I found an aeotec power line meter for pennies on the dollar. It took a lot of work to connect it to vera i.e fw update, zwave parameter changes, etc. I found all the information to do so online and got it to pull in. Unfortunately, it is the only device I have added to vera thus far, that HA has not picked up. After reading several forums I found this get command, and created the sensor. It was working fine, showing relatively accurate results (consistent to changes) but the value it was pulling in had no unit (I knew it was Watts) in HA so it was not being tracked in history. To do this I created a template sensor to grab the state and convert it to kW.
Here is the full yaml.
- platform: rest
resource: http://192.168.X.X:1706/data_request?id=variableget&DeviceNum=20&serviceId=urn:micasaverde-com:serviceId:EnergyMetering1&Variable=Watts
method: GET
name: Power Line Watts
- platform: template
sensors:
energy_meter:
value_template: "{{ states.sensor.power_line_watts.state | multiply(0.001) }}"
friendly_name: Energy Meter
unit_of_measurement: 'kW'
Then a little work in groups.yaml gave me this…
Hope this helps!
Almost forgot, add this to your configuration.yaml and groups.yaml (if needed)
- platform: generic
still_image_url: https://media.giphy.com/media/3o7abslV2S4fSYUXJK/giphy.gif
name: Tacos!
Its sure to brighten your day every time you open HA!
Regards,
Thanks Guys I managed to get as far as it working when calling a service from HA using the foll:
shell_command:
open_blinds: home/pi/Switch/open.sh
close_blinds: home/pi/Switch/close.sh
Now how do I get it to show up as a button on the UI for each Open/ Close service?
I’ve tried the following but nothing shows up (excuse my noobness)
script:
Blinds:
sequence:
service: shell_command/open_blinds
Nice!
This is where groups.yaml and customize.yaml come into play.
Are you using either yet?
Yes I am using groups to group my light switches at the moment like the following:
group:
Lounge and Dining:
- switch.diningroom_light
- switch.outside_patio_light
- switch.lounge_light
- switch.lounge_ambient
Add customize: !include customize.yaml directly under the time_zone: entry in your configuration.yaml.
Create a customize.yaml file and add…
script.shell_command.open_blinds:
friendly_name: Open
icon: mdi:window-open
script.shell_command.close_blinds:
friendly_name: Close
icon: mdi:window-open
Then in groups.yaml create…
blinds:
name: Blinds
entities:
- script.shell_command.open_blinds
- script.shell_command.close_blinds
Finally add group.blinds to the default view.
This is probably not going to give you exactly what you are looking for but its all I can think of.
Also, this is just an example of the work flow. I may have messed up entities, etc.
Regards,
@ptp nice! I notice there is no interval. How often is the value updated that way?
p.s. I’m slowly moving away from my Vera as I notice that especially sensors don’t always report correct to HASS. If I pair them directly with HASS they report fine.
Thanks PtP! That explains alot! Ok I now understand how to make it appear properly in the UI but I am failing with creating the script this is what my scripts.yaml looks like:
Blindopen:
alias: 'Open Blinds'
sequence:
- service: shell_command.open_blinds
Blindclose:
alias: 'Close Blinds'
sequence:
- service: shell_command.close_blinds
but when I click activate nothing happens. If I call the shell command from the services page it works what am I doing wrong?
Try using lower case for the script names.
blindopen:
sequence:
- service: shell_command.open_blinds
blindclose:
sequence:
- service: shell_command.close_blinds
I would’ve been having sleepless nights over that! It works!!! thanks again!
Happy to help!!
I haven’t benchmarked it but if l turn on a light it updates in less than a minute.
Thanks for the heads up about the Vera. What do you plan on using?
Is this to say that instead of using the Vera platform in HA, you’re setting them up as rest sensors?
I’ve got a few sensors that I haven’t moved yet and they’re sloooow sometimes.
How often do rest sensors poll?
Hi
Can I ask you for the ESP8266 code to make the blinds work? I want to do a similar thing as you before integrating it with Homeassistant.
Many thanks.
Hi
The code I used can be found here
Enjoy!