Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. David Pinnock
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    David Pinnock

    @David Pinnock

    1
    Reputation
    12
    Posts
    471
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    David Pinnock Follow

    Best posts made by David Pinnock

    • RE: Unable to connect to /dev/ttyUSB0 [Solved]

      Thanks @gohan !! Another google about accessing usb and found some detail about adding to the dialout group. So I did this:

      sudo adduser homeassistant dialout

      It doesn't work unless you reboot but its now connecting to the usb!! I'm getting other errors about my sensors now but this is progress at least! Thanks 🙂

      posted in Home Assistant
      David Pinnock
      David Pinnock

    Latest posts made by David Pinnock

    • RE: Invalid Message, Sensor not being added

      Ok I'll try that. Think I have already tried with just sending one value in the sketch but perhaps I would also need to delete the persistent mysensors.json file for it to have a chance.

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Brilliant thanks very much for the help!

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      3.4:

      Name: pyserial
      Version: 3.4
      Summary: Python Serial Port Extension
      Home-page: https://github.com/pyserial/pyserial
      Author: Chris Liechti
      Author-email: cliechti@gmx.net
      License: BSD
      Location: /srv/homeassistant/lib/python3.4/site-packages
      
      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Installed Home Assistant manually on Raspian following the install guide

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Given up!

      Written a simple flow in NodeRed that forwards the messages on just fine.

      0_1516383923802_cfbb9bf7-e0d9-4e36-9b18-c38263905244-image.png

      [{"id":"a0e7c229.c1b2","type":"serial in","z":"c20914f0.8b8318","name":"MySensorsInput","serial":"4ba29f87.c500a","x":100,"y":68,"wires":[["c275b371.0a92a"]]},{"id":"2c003b62.b3ca04","type":"debug","z":"c20914f0.8b8318","name":"","active":true,"console":"false","complete":"true","x":976,"y":57,"wires":[]},{"id":"c275b371.0a92a","type":"function","z":"c20914f0.8b8318","name":"Decode Message","func":"var message = msg.payload;\nvar result = message.split(\";\");\nvar arrlength = result.length;\n\nmsg.payload = {};\n\nif(arrlength==6){\nmsg.payload.nodeid = result[0];\nmsg.payload.childid = result[1];\nmsg.payload.command = result[2];\nmsg.payload.ack = result[3];\nmsg.payload.type = result[4];\nmsg.payload.payload = result[5];\n} else {\n    msg.payload = \"Ignore\";\n}\n\n\n//1;1;1;0;39;8.8\n\n//1;;1;0;38;3.6\n\nreturn msg;","outputs":1,"noerr":0,"x":324,"y":68,"wires":[["5e07aa77.6b3884"]]},{"id":"5e07aa77.6b3884","type":"switch","z":"c20914f0.8b8318","name":"Filter Update Messages","property":"payload.command","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","outputs":1,"x":581,"y":68,"wires":[["764204f4.fe8bdc"]]},{"id":"a9be705b.07cec","type":"mqtt out","z":"c20914f0.8b8318","name":"","topic":"","qos":"","retain":"","broker":"9ccc9e2b.1b109","x":1018,"y":157,"wires":[]},{"id":"764204f4.fe8bdc","type":"function","z":"c20914f0.8b8318","name":"Format MQTT Message","func":"var nodeid = msg.payload.nodeid;\nvar type =  msg.payload.type;\nvar value = msg.payload.payload;\n\nmsg.payload = {}\n\nmsg.topic = \"haas/mySensors/\"+ nodeid +\"/\" + type;\nmsg.payload.string = value;\n\nreturn msg;","outputs":1,"noerr":0,"x":785,"y":157,"wires":[["a9be705b.07cec","2c003b62.b3ca04"]]},{"id":"4ba29f87.c500a","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"9ccc9e2b.1b109","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
      

      This sends updates to a couple of MQTT sensors set up in my config.

      sensor:
        - platform: mqtt
          name: "Charger Current"
          state_topic: "haas/mySensors/1/39"
          value_template: '{{ value_json.string }}'
          unit_of_measurement: 'a'
        - platform: mqtt
          name: "Charger Voltage"
          state_topic: "haas/mySensors/1/38"
          value_template: '{{ value_json.string }}'
          unit_of_measurement: 'V'
      

      Not sure if there's a better value template than string? Couldn't find any detail on what options there were..

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Well I've had about enough of this nothing I do seems to work.

      • Upgraded both my gateway and node to MySensors 2
      • Configuration.yaml seems correct as per previous post
      • Some messages seem like they are accepted but no sensors show up
        • It also seems like the Gateway may store messages or values, as some that are logged are older values?
      • PySerial is 2.6 and I can't seem to down/upgrade it whatever I do
      • strange script errors also but this could also be because of the bad data errors

      Script Error:

        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
          set_req.V_ORP: 'mV',
      

      I'm about ready to give up now, very frustrating when Domoticz is working just fine on the same RaspberryPi and gateway. I've even considered having Domoticz forward the messages on to Home Assistant! 🙂

      Could really use some help before I throw the damn Arduino out completely and buy a PiZero to see if I can use that!

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Damn it still not managed to get this working properly 😞

      This is an extract from the log:

      2018-01-16 21:56:57 INFO (MainThread) [homeassistant.loader] Loaded sensor.mysensors from homeassistant.components.sensor.mysensors
      2018-01-16 21:56:57 INFO (MainThread) [homeassistant.loader] Loaded mysensors from homeassistant.components.mysensors
      2018-01-16 21:56:57 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mysensors
      2018-01-16 21:56:58 INFO (MainThread) [homeassistant.setup] Setting up mysensors
      2018-01-16 21:56:58 INFO (MainThread) [homeassistant.setup] Setup of domain mysensors took 0.4 seconds.
      2018-01-16 21:56:58 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=mysensors>
      2018-01-16 21:57:00 DEBUG (Thread-7) [homeassistant.components.mysensors] Invalid values: {38: '3.6', 39: '8.1'}: sensor platform: node 1 child 1: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]
      2018-01-16 21:57:00 INFO (Thread-14) [mysensors.gateway_serial] Trying to connect to /dev/ttyUSB0
      2018-01-16 21:57:00 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.sensor, discovered=name=mysensors, devices=[(1843074256, 1, 1, 38), (1843074256, 1, 1, 39)], platform=mysensors>
      2018-01-16 21:57:00 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.mysensors
      2018-01-16 21:57:00 INFO (Thread-14) [mysensors.gateway_serial] /dev/ttyUSB0 is open...
      2018-01-16 21:57:00 INFO (Thread-2) [homeassistant.components.mysensors] Adding new devices: [<Entity Battery Charger 1: None>, <Entity Battery Charger 1: None>]
      2018-01-16 21:57:00 INFO (Thread-14) [mysensors.gateway_serial] Connected to /dev/ttyUSB0
      2018-01-16 21:57:00 DEBUG (Thread-12) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:00 DEBUG (Thread-12) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.1
      2018-01-16 21:57:00 DEBUG (Thread-4) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:00 DEBUG (Thread-4) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.1
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      2018-01-16 21:57:03 WARNING (Thread-14) [mysensors] Error decoding message from gateway, bad data received: 0=1,c=1,t=38,pt=7,l=5,sg=0:3.6
      2018-01-16 21:57:03 WARNING (Thread-14) [mysensors] Not a valid message: 
      2018-01-16 21:57:03 DEBUG (Thread-14) [homeassistant.components.mysensors] Node update: node 1 child 1
      2018-01-16 21:57:03 DEBUG (Thread-14) [homeassistant.components.mysensors] Invalid values: {38: '3.6', 39: '8.1'}: sensor platform: node 1 child 1: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]
      2018-01-16 21:57:03 DEBUG (Thread-9) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:03 DEBUG (Thread-9) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.1
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      2018-01-16 21:57:03 DEBUG (Thread-14) [mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,1-1-0,s=1,c=1,t=39,pt=7,l=5,sg=0:8.2
      2018-01-16 21:57:03 DEBUG (Thread-7) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:03 DEBUG (Thread-7) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.1
      2018-01-16 21:57:03 DEBUG (Thread-14) [homeassistant.components.mysensors] Node update: node 1 child 1
      2018-01-16 21:57:03 DEBUG (Thread-14) [homeassistant.components.mysensors] Invalid values: {38: '3.6', 39: '8.2'}: sensor platform: node 1 child 1: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      2018-01-16 21:57:03 DEBUG (Thread-4) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:03 DEBUG (Thread-4) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.2
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      2018-01-16 21:57:03 DEBUG (Thread-8) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:03 DEBUG (Thread-8) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.2
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      2018-01-16 21:57:08 DEBUG (Thread-14) [mysensors] n:0 c:255 t:3 s:9 p:TSF:MSG:READ,1-1-0,s=1,c=1,t=38,pt=7,l=5,sg=0:3.6
      2018-01-16 21:57:08 DEBUG (Thread-14) [homeassistant.components.mysensors] Node update: node 1 child 1
      2018-01-16 21:57:08 DEBUG (Thread-14) [homeassistant.components.mysensors] Invalid values: {38: '3.6', 39: '8.2'}: sensor platform: node 1 child 1: S_MULTIMETER requires value_type V_IMPEDANCE @ data[14]
      2018-01-16 21:57:08 DEBUG (Thread-5) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      2018-01-16 21:57:08 DEBUG (Thread-5) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 39, value = 8.2
        File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/mysensors.py", line 68, in unit_of_measurement
      

      To me, this looks like it should be working. There are some invalid data messages but there are also valid ones which appear to post valid sensor data.

      This looks like a valid update for example:

      2018-01-16 21:57:03 DEBUG (Thread-7) [homeassistant.components.mysensors] Entity update: Battery Charger 1: value_type 38, value = 3.6
      

      Current configuration in HASS:

      mysensors:
        gateways:
          - device: '/dev/ttyUSB0'
            persistence_file: '/home/homeassistant/.homeassistant/mysensors.json'
            baud_rate: 115200
            nodes:
               1:
                  name: "Battery Charger"
        optimistic: false
        persistence: true
        retain: true
        version: 2
      

      Maybe I need to define the sensors here?! I've tried updating pyserial but whatever I do (including uninstall and reinstall) it still seems to remain on 2.6.

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Invalid Message, Sensor not being added

      Ok that seems to have worked... once...

      The sensors appeared in HASS but are not now updating, getting these errors:

      0_1515927681773_87da4b70-8634-46c1-a26a-b671bab453b0-image.png

      I think I read another thread about Pyserial being an issue so wondering if this is causing these errors..

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • Invalid Message, Sensor not being added

      Having managed to get HASS to connect to the USB I am now unable to get the sensor recognised 🙂

      HASS is logging the following error:

      0_1515837980561_7c136908-fe6d-4fec-8ced-d16ee5662e6a-image.png

      My sketch appears similar to the example here: https://home-assistant.io/components/sensor.mysensors/

      I'm using an S_MULTIMETER to send V_VOLTAGE and V_CURRENT values but not V_IMPEDANCE.

      Tried changing the child_id to 255 in the sketch but no luck so switched it back to 1.

      #include <SPI.h>
      #include <MySensor.h>
      
      //#define DEBUG_ON  // comment out this line to disable serial debug
      #define CHILD_ID 1
      
      MySensor gw;
      
      MyMessage msgVolts(CHILD_ID, V_VOLTAGE);
      MyMessage msgAmps(CHILD_ID, V_CURRENT);
      // Possible variable types for multimeter:  V_VOLTAGE, V_CURRENT, V_IMPEDANCE
      
      
      unsigned long SLEEP_TIME = 5000;  // sleep time between reads (seconds * 1000 milliseconds)
      int oldVoltage = 0;
      int oldCurrent = 0;
      int VOLTAGE_SENSE_PIN = A1;  // select the input pin for the battery sense point
      int CURRENT_SENSE_PIN = A2;  // select the input pin for the battery sense point
      
      
      
      
      
      void setup()  
      {
      
        gw.begin();
        gw.present(CHILD_ID, S_MULTIMETER);
        
         // Send the sketch version information to the gateway and Controller
         gw.sendSketchInfo("Battery Charger", "1.0");
      
        pinMode(VOLTAGE_SENSE_PIN, INPUT);
        pinMode(CURRENT_SENSE_PIN, INPUT);
      
        #ifdef DEBUG
          Serial.begin(9600);
        #endif
      
      }
      
      
      
      
      
      void loop()
      {
         // get the battery Voltage
      
        int     voltageLevel = analogRead(VOLTAGE_SENSE_PIN);
        int     currentLevel = analogRead(CURRENT_SENSE_PIN);
        double  levelinVolts = voltageLevel*0.0492903225806452;
        double  levelinAmps  = currentLevel*0.041125;
      
      
        #ifdef DEBUG
          Serial.println(voltageLevel);
          Serial.println(currentLevel);   
          
          Serial.print("Voltage:");    
          Serial.print(levelinVolts);
          Serial.print("v ");    
          
          Serial.print(" Current:");    
          Serial.print(levelinAmps);
          Serial.print("a MaxAmps:");    
          //Serial.print(maxAmps);    
          Serial.println("a ");    
        #endif
      
      //   if (oldVoltage != levelinVolts) {
           // Power up radio after sleep
            gw.send(msgVolts.set(levelinVolts,1));
            
           oldVoltage = levelinVolts;
      //   }
      
      //  if (oldCurrent != levelinAmps) {
           // Power up radio after sleep
          gw.send(msgAmps.set(levelinAmps,1));
            
          oldCurrent = levelinAmps;
      //  }
        
         gw.sleep(SLEEP_TIME);
      }
      

      (I'm no Arduino expert and most of the sketch was adapted from a similar example I found.)

      Looking at how its set in Domoticz it does seem like the node itself has an id of 255 but I don't see anywhere to set that? Maybe I should add this manually to the configuration.yaml some how?!

      posted in Home Assistant
      David Pinnock
      David Pinnock
    • RE: Unable to connect to /dev/ttyUSB0 [Solved]

      Thanks @gohan !! Another google about accessing usb and found some detail about adding to the dialout group. So I did this:

      sudo adduser homeassistant dialout

      It doesn't work unless you reboot but its now connecting to the usb!! I'm getting other errors about my sensors now but this is progress at least! Thanks 🙂

      posted in Home Assistant
      David Pinnock
      David Pinnock