Virtual switch for URL Action codes

Hello,

I want to integrate my PEHA PHC 942 STM domotica-system in HA. This because PEHA only support his own brand devices and Enocean wireless devices but no audio-systems, webcams etc.

I can control the 942 STM (also) via URL-action codes. It works already via IFTTT on my Google home(s) and Alexa dot (outside HA) but i don’t have a clue how to make a (virtual) switch within HA that can execute a URL Action code. So for example something like beneath:

##__configuration.yaml
switch:
platform: command_line
switches:
vswitch1:
command_on: http://IPAddr_942:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2
command_off: http://IPAddr_942:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2
friendly_name: Light Office

group:
default_view:
view: yes
icon: mdi:home
entities:
- switch.vswitch1

Further i already integrated Alexa and Google home in HA, so when i could find how to execute URL Action codes it would work voice controlled without the use of IFTTT.

Thanks in advance,
Léon Jehae

according to the documentation the part above for the switch should work as long as it is formatted correctly.

if you select your code snippet above and click the </> button in the editor window it will display the way you have it formatted in your config. if it is incorrect then we can see it.

Hello finity,

Thanks for your reply, what do yoy mean with “</> button in the editor window”?
E.g. where is the </> button and where is the editor window? (I’m new with HASS)

I now use a samba-share (mounted to /config) with notepad to set things in the configuration.yaml.
Should i do otherwise?

Best regards,
Léon

PS. Is there a (downloadable) manual for HASS so i don’t have to sit hours behind a computer? (i have a hernia at the moment)

when you are typing to add (or edit) a post, where you are typing is what I call the editor window. at the top of that window is where you will find the symbol to click to properly format the code.

It’s best to do that any time you post any code because yaml is very spacing critical. that way people can see exactly how you have it entered into your config and can spot potential issues.

how you edit your code isn’t as big of a concern as long as the editor you use doesn’t do any funky hidden formatting to it. I use WinSCP and Notepad++. Others use different editors. As far as I know Notepad should be OK but I’ve not used it for code editing so take that for what it’s worth.

And unfortunately, no there isn’t any “manual” per se. Just the online documentation. It is easier to maintain for the developers I guess. However my biggest complaint has always been the vague/scant/incomplete documentation for home assistant.

The good news is that the forum here is usually very helpful with lots of very knowledgeable people. If it hasn’t already been answered and found in a forum search, most times (most…:wink:) someone should eventually be around to help you out.

Hello finity,

hahahaha, you where talking about the post window…i thought you meant the edit window within HA.:roll_eyes: I let you know asap.

switch:
  platform: command_line
  switches:
    vswitch1:
      command_on: curl http://10.10.10.2:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2
      command_off: curl http://10.10.10.2:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2
      friendly_name: Kantoor verlichting
2 Likes

Like i said, when i put the url in a browser the bulb is switched, so the action code is 100% correct. The button it self reacts in HA but nothing happens with the light bulb

if you type the complete command directly into a linux shell terminal from where you have Home Assistant installed exactly as you have it in your configuration does the light switch on/off?

Nope, if i type : http://10.10.10.2:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2 in a browser on my windows desktop the light is switching.

If i type : curl http://10.10.10.2:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2 in the linux terminal on the Home Assistant server then i get this message :

try putting " " around the http://… portion of the command.

like:

curl "http://10.10.10.2:80/postEvent.html?action=input&STM=0&MOD=1&CHA=14&EVT=2"

The HA-server (on Docker on Synology DS918+) has the same ip-adress as the NAS and the PEHA-PLC is pingable from there at 10.10.10.2

Hi finity, with the " " it is now working also from the terminal console, i will try it again via my configuration.yaml and let you know.

good. i think it should work in the switch that way now, too.

1 Like

Hello “Master” finity, it is now working in Home Assistant. Finity for President, 1000x THNX and always willing to do something in return.

Awsome! And you’re welcome.

I’m far from a master. As they say, “even a blind squirrel finds a nut occasionally”. :wink:

For what it’s worth, i finally found reasonable documentation :
https://developers.home-assistant.io/en/

I wasn’t looking on the developers section because i thought it was only for programmers but the architecture of HA explains a lot.

Hi there,
where exactly is this code entered.
I also use Peha PHC and have installed Home Assistant on the Synology NAS.

In the configuration.yaml define a virtual switch


Hi Leon,

I also have Peha in house and thanks to your post I started more or less with HA !

I tried this post here in my house and it’s working :yum:

Did you find a way to get the status of a light ? Now I have to work with two buttoms (ON/OFF) and you can not see if the light is on or off…

And if you have other stuff to share about the integration of Peha in HA, please let me know :wink:

Thankfully greetings of Belgium !

Dag Christian,

Dan kunnen we ook gewoon in het “Belgisch” verder communiceren wat jij?..hahaha

Nee, eerlijk gezegd heb ik dat een jaar of wat geleden uitgezocht maar verder weinig tijd meer gehad voor HA, druk druk druk. Misschien dat ik tijdens de Kerst er weer eens verder naar kijk want een terugmelding was ik toen ook naar aan het zoeken maar gestopt omdat het slechts hobby is en ik verder (te) druk ben met mijn werk.

Wellicht dat het ergens in de PHC-software te vinden is binnen LED-terugmeldingen ergens in de vorm van een event?

Je zou ook PEHA kunnen benaderen waar de URL’s te vinden zijn van de terugkoppelingen zonder iets over HA te noemen. Als je het eerder vind qua tijd mag je het mij vertellen…hahahaha, ga daar voorlopig niet veel tijd meer insteken. Heb er mijn airo’s en muziek (o.a. ROON) inzetten, twee camera’s, Tuya spul en wat Geo.

Veel plezier met het onderzoeken van alle mogelijkheden en alvast fijne feestdagen,

Leon