Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




221 posts

Master Geek

Lifetime subscriber

#270142 25-Apr-2020 11:25
Send private message quote this post

I have all the necessary hardware and can operate the blinds using 'screen' on a raspberry pi via a USB RS485 Cable connected to the blind WiFi bridge.

 

To connect to the bridge

 

screen /dev/ttyUSB0 9600

 

Issue Open Command
!123D001o;
Issue Close Command
!123D001c;

 

What is the best way to send these commands from Home Assistant, ideally I would like to create a switch in Home Assistant to operate the blinds, with an Open and a Close toggle.

 

What is the best way to implement this?


Create new topic
23385 posts

Uber Geek

Trusted
Subscriber

  #2471088 25-Apr-2020 14:44
Send private message quote this post

Node red can talk to serial ports. I followed along an example and had it working but then changed to using an esp8266 instead so I got electrical disconnection from the device.





Richard rich.ms

453 posts

Ultimate Geek


  #2471265 25-Apr-2020 19:43
Send private message quote this post

I've done this in Node Red, albeit for a different device. Node Red is easy to setup using Home Assistant Add-Ons.

 

What blinds are you using?


 
 
 
 




221 posts

Master Geek

Lifetime subscriber

  #2471296 25-Apr-2020 20:38
Send private message quote this post

A couple of different brands, some honeycomb blinds (Kinetics) and a roller blind (ABC Blinds) ultimately both are dooya motors.  Both use the DD7002B wif-fi bridge

 

I've made progress, I can operate the blinds now from the command line.

 

( stty raw speed 9600 >&2; echo -ne '!123D001o;' ) >/dev/ttyUSB0 <&1

 

Although the following switch does not work

 

switch:
  platform: command_line
  switches:
    nw_dining_blind:
      command_on: "( stty raw speed 9600 >&2; echo -ne '!123D001o;' ) >/dev/ttyUSB0 <&1"
      command_off: "( stty raw speed 9600 >&2; echo -ne '!123D001c;' ) >/dev/ttyUSB0 <&1"
      friendly_name: North West Dining Blind

 

I don't know if it's character escaping or if I need to run it as a script.


560 posts

Ultimate Geek


  #2471332 25-Apr-2020 23:22
Send private message quote this post

fearandloathing:

 

A couple of different brands, some honeycomb blinds (Kinetics) and a roller blind (ABC Blinds) ultimately both are dooya motors.  Both use the DD7002B wif-fi bridge

 

I've made progress, I can operate the blinds now from the command line.

 

( stty raw speed 9600 >&2; echo -ne '!123D001o;' ) >/dev/ttyUSB0 <&1

 

Although the following switch does not work

 

switch:
  platform: command_line
  switches:
    nw_dining_blind:
      command_on: "( stty raw speed 9600 >&2; echo -ne '!123D001o;' ) >/dev/ttyUSB0 <&1"
      command_off: "( stty raw speed 9600 >&2; echo -ne '!123D001c;' ) >/dev/ttyUSB0 <&1"
      friendly_name: North West Dining Blind

 

I don't know if it's character escaping or if I need to run it as a script.

 

 

My guess would be that you have to execute a program to run the script line.  So try adding "/bin/bash -c " at the front.




221 posts

Master Geek

Lifetime subscriber

  #2471571 26-Apr-2020 13:12
Send private message quote this post

fe31nz:

 

My guess would be that you have to execute a program to run the script line.  So try adding "/bin/bash -c " at the front.

 

 

Give that person a beer

 

Solution

 

switch:
  platform: command_line
  switches:
    blind_dining_nw:
      command_on: '/bin/bash -c "( stty raw speed 9600 >&2; echo -ne ''!123D001o;'' ) >/dev/ttyUSB0 <&1"'
      command_off: '/bin/bash -c "( stty raw speed 9600 >&2; echo -ne ''!123D001c;'' ) >/dev/ttyUSB0 <&1"'
      friendly_name: Blind Dining North West

 

 

 

That is the whole line wrapped in: '

 

' escaped around the !123D001o;

 

and the command line pushed to bash wrapped in "


560 posts

Ultimate Geek


  #2471776 26-Apr-2020 22:50
Send private message quote this post

And now that it works with bash, if you want it to run slightly faster and with lower overheads, you might like to see if it will also work with /bin/sh.




221 posts

Master Geek

Lifetime subscriber

  #2471777 26-Apr-2020 22:56
Send private message quote this post

Is it worth it when the response is instant?

 
 
 
 


560 posts

Ultimate Geek


  #2472466 27-Apr-2020 23:48
Send private message quote this post

Bash is a big powerful shell with a massive feature set.  It is OK to use it for this sort of thing but if sh will work, it is better to use sh as bash is way overkill for the job.  If you have RAM and processor to waste and bash is not being used very often, you probably will not notice any difference.  If you use bash like this for something that happens say every second, then you will likely have problems.  Here are the sizes of bash and sh (dash) in Ubuntu 18.04:

 

root@mypvr:~# ll /bin/bash
-rwxr-xr-x 1 root root 1113504 Jun  7  2019 /bin/bash*
root@mypvr:~# ll /bin/sh
lrwxrwxrwx 1 root root 4 Oct  6  2018 /bin/sh -> dash*
root@mypvr:~# ll /bin/dash
-rwxr-xr-x 1 root root 121432 Jan 25  2018 /bin/dash*

 

So sh (dash in Ubuntu) is 10.9% of the size of bash!

 

The normal thing to do with command lines like this is to try them with bash, and see if they work.  You do this because what you are trying to do may not be possible in sh as it may lack a necessary feature, and you want to initially just get them to work, rather than bothering about what features they need that may not be in sh.  Then try again with the restricted feature set of sh.  If they work in sh, then use sh.  If not, then you may need to rewrite the command to do things using sh only features, or you may decide that bash is fine and just keep using bash.


Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

National Institute for Health Innovation develops treatment app for gambling
Posted 6-Jul-2020 16:25


Nokia 2.3 to be available in New Zealand
Posted 6-Jul-2020 12:30


Menulog change colours as parent company merges with Dutch food delivery service
Posted 2-Jul-2020 07:53


Techweek2020 goes digital to make it easier for Kiwis to connect and learn
Posted 2-Jul-2020 07:48


Catalyst Cloud launches new Solutions Hub to support their kiwi Partners and Customers
Posted 2-Jul-2020 07:44


Microsoft to help New Zealand job seekers acquire new digital skills needed for the COVID-19 economy
Posted 2-Jul-2020 07:41


Hewlett Packard Enterprise introduces new HPE GreenLake cloud services
Posted 24-Jun-2020 08:07


New cloud data protection services from Hewlett Packard Enterprise
Posted 24-Jun-2020 07:58


Hewlett Packard Enterprise unveils HPE Ezmeral, new software portfolio and brand
Posted 24-Jun-2020 07:10


Apple reveals new developer technologies to foster the next generation of apps
Posted 23-Jun-2020 15:30


Poly introduces solutions for Microsoft Teams Rooms
Posted 23-Jun-2020 15:14


Lenovo launches new ThinkPad P Series mobile workstations
Posted 23-Jun-2020 09:17


Lenovo brings Linux certification to ThinkPad and ThinkStation Workstation portfolio
Posted 23-Jun-2020 08:56


Apple introduces new features for iPhone iOS14 and iPadOS 14
Posted 23-Jun-2020 08:28


Apple announces Mac transition to Apple silicon
Posted 23-Jun-2020 08:18



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.