logo elektroda
logo elektroda
X
logo elektroda

Domoticz: Switch control via URL - problem with '&' sign in camera

starob 2001 22
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18937401
    starob
    Level 29  
    Controls the switch in domoticz by calling in the browser
    Code: HTML, XML
    Log in, to see the code

    command & param enters correctly - please disregard that above is wrong :) .

    and it works, it also works the same call as an "event" on the intercom.
    I wanted to light up the light in front of the house also using the camera as "motiondetection".
    When I enter the same in the camera as event, the camera clicks on the "&" sign as not allowed.
    I have read and changed to
    http:\\192.168.2.19:8080/json.htm?type=command%26param=switchlight%26idx=20%26switchcmd=On

    Which is in line with the Domoticz documentation, but it doesn't work from the camera or the browser.
    Perhaps someone can advise how to work around this?
  • ADVERTISEMENT
  • #2 18937641
    xury
    Automation specialist
    You made me curious about this and it actually doesn't work in Domoticz %26 instead of &.
    I get a return JSON after sending:
    Code: JSON
    Log in, to see the code
    .
  • #3 18937657
    starob
    Level 29  
    Exactly...no % works
  • #4 18937672
    xury
    Automation specialist
    Ok then we will look for another way, What kind of camera is it? What besides the url can be released from it as an event?
  • ADVERTISEMENT
  • #5 18937704
    starob
    Level 29  
    Vivotek IB836, email, ftp.
    You can set the output as an event and query the status, but this is not an elegant solution
  • Helpful post
    #6 18937762
    xury
    Automation specialist
    Ok I understand that you have Domoticz. Do you also have Node-Red set up and are you using MQTT on the same machine as Domoticz? If so I already have a solution to your problem worked out.
    [edit]
    Basically mqtt not needed but Node-Red essential.
  • #7 18937790
    starob
    Level 29  
    xury wrote:
    Node-Red and are you using MQTT on the same machine as Domoticz?
    .
    This is a prerequisite?...I have one set up somewhere for a trial, but there was never a need to use it.
    It was a long time ago but I remember it working.
    Somehow it worked out that I prefer to write my own plugins.
  • Helpful post
    #8 18937802
    xury
    Automation specialist
    Ok then I think you can manage. Since you're writing the plugins yourself maybe you'll understand the principle and rework yourself differently. And node red is worth having because it's a mega powerful tool. With node red I am able to integrate everything into everything.
    So yes:
    Node red has to be put up and running.
    You import my flow and do the deploy. And that's basically it.
    The rule of thumb is that the camera sends an event to node-red, and node-red sends back to domoticz
    In the webcam, instead of the url to the domoticz API, you type: http://192.168.2.19:1880/starob
    That is, the simplest possible url. The webcam will accept it for sure.
    And here is the flow you have to import:
    Code: JSON
    Log in, to see the code
    .
  • #9 18938292
    starob
    Level 29  
    Thank you mate for your help :) .

    As far as I am concerned this is a big help.
    The water level on the Vistula is like this:

    1. i installed node-red on the synology as docker - works.
    2. on the same synology as a debian virtual machine (domotycz)
    3 I created a flow - it works.
    4. from the browser page it controls.
    5. the same copied address typed into the camera does not work

    The conclusion is that there is a bug in the camera itself.
    When I type from the page the debug registers msg.payload - from the camera silence.
    The camera has a button to test the connection to the server and when it tries e.g. some page (http://192.168.2.19:8080/#/Weather or http://192.168.2.19:8080) -HTTP transmission succeeded.
    Already calls http://192.168.2.145/html/ -HTTP transmission failed , where the above addresses from the browser work normally.

    Something ??? the camera is expecting back
  • #10 18938431
    xury
    Automation specialist
    Unfortunately I don't have such a camera, so I can't help much. It's strange, by the way, because the camera should send a query even though it doesn't receive a response. Although the answer is there. That's what the pseudo header page is for. Perhaps the GET method is not working and you need to try it with POST. It is also possible that the camera cannot have an empty parameter. Try replacing /starob with e.g. /starob?move=on If it doesn't help, I'll figure something out tonight.
  • ADVERTISEMENT
  • #11 18938460
    starob
    Level 29  
    Change to POST works :) .

    You could say that the problem is solved. However, it still doesn't feel like it and I still need to brush up.
    I had changed to mac to POST before but I was trying from a browser and it didn't work, hence the confusion.

    What and where would I still need to install to have an MQTT 'gateway' to support more devices.
  • #12 18938485
    xury
    Automation specialist
    Once you start playing with Node-Red and fully understand its power and potential, you'll stay with it forever.
    E.g. you can use the camera and telegram messenger to send short videos from in front of the house when someone rings the doorbell. Have a look at the link to the topic in my signature.
    For coarser play, you also need to master MQTT, which has become somewhat of an IoT staple.
  • #13 18938551
    starob
    Level 29  
    xury wrote:
    See link to topic in my signature


    I've seen it before - a piece of good work. :spoko:

    I've also committed a couple of integrations - they work for me but are so splattered it's a shame to publish ;) :
    -Ventus W266 weather station - RF869MHz gateway <> mysensors (ESP8266)
    -Viessman boiler - optolink gateway <> mysensors (ESP8266)
    -irrigation controller - in-house design (ESP8266)
    -Sofar Solar inverter (modbus)
    -Sydar Solar inverter (ESP8266) -Sydar Solar energy meter SMD630 (modbus)
    -audio player iEAST

    Added after 2 [minutes]: .

    xury wrote:
    when someone rings the gate
    .
    I have a video door phone so this is solved systemically.
  • #14 18940042
    starob
    Level 29  
    xury wrote:
    For coarser play, you also need to master MQTT, which has become somewhat of an IoT staple.


    You have convinced me!!! ;)

    For starters, I rewrote your flow to turn on the light via MQTT
    Domoticz: Switch control via URL - problem with '&' sign in camera

    I've been looking through the examples and it doesn't look as difficult as it seemed before.
  • Helpful post
    #15 18940073
    xury
    Automation specialist
    Well, that's nice. All it takes is a little mastery of JavaScript then node Function does an amazing job. Other useful features include data storage thanks to context,flow, global. Then you can get on with the Dashboard and forget about the nasty Domoticz GUI. And with MQTT you can get a lot more information from e.g. Tasmot-based devices.
    I don't use the Domoticz tab in Tasmota at all. I download all the necessary data from MQTT and send it to domoticz/in. In turn, I gather feedback from domoticz/in and am sure of the action.
    In general, the versatility of Node-Red is that it can work as a data exchange broker in an easy-to-image way, as well as a data creator. With additional nodes installed, other devices such as Xiaomi, various gateways such as the homemade milight hub etc. can be supported. You can send data to databases such as MySQL, Influxdb, etc.
    You can do charts, automation, etc. You can transfer data between different flows. You can support modbus, knx, serial usart etc. And best of all it uses very few resources.
    I am in the process of switching to Home Assistant and it is thanks to node red that HA does not bite with Domoticz running simultaneously. By passing data to each other.
  • #16 18940264
    starob
    Level 29  
    xury wrote:
    I'm in the process of switching to Home Assistant and just thanks to node red this HA doesn't clash with Domoticz running at the same time.
    .
    This was on my mind too, but I didn't know how to reconcile the partial transfer of devices to HA.
    Is it possible (I'm not asking for details) to move more sensors and all the automation to node-red without compromising the functionality of domoticz? Doing it in stages to such a state that domoticz works as a "terminal" with only one "MQTT -Client" device.

    " Andrzej used to j..no " :) .
  • #17 18940283
    xury
    Automation specialist
    Yes it is, but it already depends on the sensors how they communicate with Domoticz. The most convenient thing would be to just leave Domoticz and let it run. Turn on the MQTT loop and collect data for HA from Domoticz via domoticz/out.
    Except that you have to be careful not to loop Domoticz. In my case, these are sophisticated solutions. A simple way is to use a node RBE which will pass a payload with a different state, and if it is the same it will stop it. Sometimes when I look at my flows I find that I have lost myself in my joy of looping.
    In my spare time, when I'm sure I've cleared my flows of API keys and other sensitive data, I'll make them available here on the electrode. They are quite complicated and would have to be dealt with piece by piece. An additional difficulty is that I tried to make my whole ecosystem so that even in the event of a server failure it would still have basic functionality, i.e. manual control of switches and heating.
  • #18 18940307
    starob
    Level 29  
    Thanks for now - I need to grasp the subject a bit, if only to understand what you are writing about.
  • ADVERTISEMENT
  • #19 18947674
    starob
    Level 29  
    xury wrote:
    The most convenient thing would be to just leave Domoticz and let it run.


    This is what I have done. However, I am not making Domoticz available via mqtt (for now)
    To start with:
    1. I changed the type of one of the mysensors gateways from Lan to MQTT, controlling the pond hardware. This is set up on a Sonoff 4ch.
    2. I changed only the gateway type to mqtt in the domotics. As a result, I have not lost anything.
    3. in HA I have added
    
    mysensors:
      gateways:  
        - device: mqtt
    #      persistence_file: 'config/mysensors1.json'
          topic_in_prefix: 'oczko-out'
          topic_out_prefix: 'oczko-in'
        - device: mqtt
    #      persistence_file: 'config/mysensors1.json'
          topic_in_prefix: 'ventus-out'
          topic_out_prefix: 'ventus-in'      
      optimistic: false
      persistence: true
      retain: true  
    
    .

    so that ( I think) both systems run in parallel and update each other. Why mysensors? - For a beginner it is easier as the devices add themselves automatically.

    3. in node-red I made a simple automation to protect against dry-running of the UV lamp.

    I did the same with the weather station, I just don't like the lack of a compass for wind direction (the degrees are not very readable).

    The problem I have is with rflink, which I make available to HA via ser2net on a port.
    It generally works, but overnight it caught all devices on 433Mhz in the area.

    Maybe you can advise how to hook into the rflink serial in node using IP:port (how to read the serial via IP:P ORT?).
    Ultimately I figured I'd filter out only the ones I'm interested in and make them available via mqtt to HA.

    ps. what is this MQTT add-on in HA, what is it for - I haven't installed it but it works?
  • #20 18949465
    starob
    Level 29  
    starob wrote:
    Maybe you can advise how to connect to the rflink serial in the node using IP:port (how to read the serial over IP:P ORT?).


    I wrapped - via "TCP in node".
    Initially it didn't work due to Ser2Net dropping one connection. At the moment I am at the stage of publishing topics.

    Domoticz: Switch control via URL - problem with '&' sign in camera .

    I wonder if the RFLink/out/<unique sensor ID> topic will be a good solution.

    Now I need to work on "msg.payload", at my current level of knowledge it is useless for now.... but it is :) .
    Before that, however, I will try serving rflink by connecting to a Mikrotik router.
    Currently Ser2Net with two clients is losing messages.
  • #22 18950157
    starob
    Level 29  
    I have tried before - to no avail - the reason being the bad luck to select a sensor with a name containing spaces for testing.
    "Rflink in" doesn't buy it. The "Parse message" function doesn't do anything much but replace the space with "_" and that was enough.

    Domoticz: Switch control via URL - problem with '&' sign in camera .

    It is possible to share the rflink on the network using a Mikrotik router with USB or RS with a passthrough, unfortunately only one connection - maybe useful for someone.
    Domoticz: Switch control via URL - problem with '&' sign in camera

    Domoticz: Switch control via URL - problem with '&' sign in camera .

    For today, ;) is enough.
  • #23 18955069
    starob
    Level 29  
    The progress is significant. I have already moved most of the equipment to HA.

    I got stuck on reading the door detector status from the control panel in node-red.
    I already have the Satel control panel integrated into HA and the detector states are correct.
    I tried node-red-contrib-home-assistant (all three) but there is an authorisation problem (I generated new tokens) - I don't know something! The guides on the internet are no match for what I have.

    .. another idea:
    Is there any way to publish the state of the detector in the MQTT topic, or even everything as it flies - similar to domoticz?

Topic summary

The discussion revolves around controlling a switch in Domoticz via a URL command, specifically addressing issues with the '&' character when used in a camera's event configuration. The user initially faced problems with the command not executing correctly due to the camera rejecting the '&' symbol. After several attempts, including changing the command format to use '%26', it was determined that the camera does not support this format. A solution was found by switching the method from GET to POST, which successfully executed the command. The conversation also explored the integration of Node-Red and MQTT for enhanced functionality, with users sharing experiences and configurations for better device management and automation.
Summary generated by the language model.
ADVERTISEMENT