New to hass (Magnetic door sensor, multi sensor, power consumption reading, mail box sensor)

321 views
Skip to first unread message

Patrik Olsson

unread,
Nov 3, 2015, 1:42:09 PM11/3/15
to Home Assistant Dev
Hello I have used openhab before but I have switched over to Home Assistant and I love it!!

But I have a couple of questions as below:
  • How to use WINDOW/DOOR MAGNETIC SENSOR and especial the Nexa LMST-606, before I used a Python script and updated a device in openhab true REST api to change the state open/close. What is the best way to handle that in Home Assistant?
  • How to I tell Home Assistant to show a badge for a specific item like a camera. All my badges disperse when I added the device to a group.
  • A also have planes on reading my power meter to see my power consumption with a nodeMCU and aREST, what is the best way to integrate that type of function?
  • I'm also looking on a mailbox notification and also there I would like to have a item in the GUI that I use as a trigger to send a notification with slack.
  • And last I want to build a multi sensor based on nodeMCU and aRest with temperature, humidity, light, PIR sensor. Anyone that have a good idee to integrate that in hass?
Hope some one can show me the way:)

Fabian Affolter

unread,
Nov 3, 2015, 6:31:33 PM11/3/15
to Home Assistant Dev

On Tuesday, November 3, 2015 at 7:42:09 PM UTC+1, Patrik Olsson wrote:

But I have a couple of questions as below:
  • How to use WINDOW/DOOR MAGNETIC SENSOR and especial the Nexa LMST-606, before I used a Python script and updated a device in openhab true REST api to change the state open/close. What is the best way to handle that in Home Assistant?
Perhaps you can reuse your script with the command_switch. But as you are writing about REST API, there is a REST switch.
  • How to I tell Home Assistant to show a badge for a specific item like a camera. All my badges disperse when I added the device to a group.
 Hmmm, I don't know if I understand you right. The groups are designed to collect/organize frontend entries meaning that if you add sensor to a group the badge will not show up anymore.
  • A also have planes on reading my power meter to see my power consumption with a nodeMCU and aREST, what is the best way to integrate that type of function?
 Using the aREST sensor.
  • I'm also looking on a mailbox notification and also there I would like to have a item in the GUI that I use as a trigger to send a notification with slack.
Do you meaning sending email with mailbox notification? If so, then the SMTP notification platform is at your service. Home Assistant has no native support for checking mailboxes for newly arrived messages. I guess that this could be done with a little help from an external script and the command line sensor
  • And last I want to build a multi sensor based on nodeMCU and aRest with temperature, humidity, light, PIR sensor. Anyone that have a good idee to integrate that in hass?
The downside of the nodemcu platform is the lack of analog input options. There is only one analog pin available. Depending on your choice of the physical sensors for the variables you want to measure, this is not really an issue because a library is taking care of the output (like the DHTxx library). Integration could be done again with the aREST sensor or MQTT.

Kind regards,

Fabian

Patrik Olsson

unread,
Nov 5, 2015, 1:54:37 PM11/5/15
to Home Assistant Dev
Thanks for your replay Fabian, I think you understood me almost correct what I meant with the mailbox was actually a real physical mailbox to sens when the postman have but any mail in there.

 I made a Python script like below to get my door sensor working, it's not pretty but it works.

Now I see the senor in the frontend and it shows Open or Close depending on the doors state. The icon is a eye, how can I change it? 

import web
from requests import post
import json
import time
import re
import threading
import tellcore.telldus as td
import tellcore.constants as const

#*********************************************
#['class:command', 'protocol:arctech', 'model:selflearning', 'house:48801126', 'unit:1', 'group:0', 'method:turnon', '']
#['class:command', 'protocol:arctech', 'model:selflearning', 'house:15632982', 'unit:10', 'group:0', 'method:turnoff', '']
urls = (
    '/pantry_door', 'index'
)

old_value = "Closed"
old_sensor = "sensor.skafferidrr"

def raw_event(data, controller_id, cid):
   
    global old_value 
    global old_sensor
    
    splitedData = str(data).split(';');
    if(len(splitedData) == 8):
        if(splitedData[0]=='class:command' and splitedData[1]=='protocol:arctech' and splitedData[2]=='model:selflearning'):
            if(splitedData[3]=='house:48801126' and splitedData[4]=='unit:1'):
                old_value = 'Open'
                old_sensor = 'sensor.skafferidrr'
                sendNewStateToHass('sensor.skafferidrr', 'Open')
            elif(splitedData[3]=='house:15632982' and splitedData[4]=='unit:10'):
                old_value = 'Closed'
                old_sensor = 'sensor.skafferidrr'
                sendNewStateToHass('sensor.skafferidrr', 'Closed')
                        
            string = "[RAW] {0} <- {1}".format(controller_id, data)
            print(string)
    

def sendNewStateToHass(entity_id, value):  
    headers = {'x-ha-access': 'kaffeKAKA2015',
            'content-type': 'application/json'}
    data = {"state": str(value)}
    
    response = post(url, data=json.dumps(data), headers=headers)
    print(response.text)
    

class MyWebserver(threading.Thread):
    
    def run (self):
        app = web.application(urls, globals())
        app.run()
        

class index():
    def GET(self):
        global old_value 
        return '{ "return_value" : "'+old_value+'" }'
        
try:
    import asyncio
    loop = asyncio.get_event_loop()
    dispatcher = td.AsyncioCallbackDispatcher(loop)
except ImportError:
    loop = None
    dispatcher = td.QueuedCallbackDispatcher()
        
core = td.TelldusCore(callback_dispatcher=dispatcher)
callbacks = []
callbacks.append(core.register_raw_device_event(raw_event))

if __name__ == "__main__":
    
    MyWebserver().start()
    
    while True:
        core.callback_dispatcher.process_pending_callbacks()
        time.sleep(0.5)


Fabian Affolter

unread,
Nov 10, 2015, 6:50:15 PM11/10/15
to Home Assistant Dev
On Thursday, November 5, 2015 at 7:54:37 PM UTC+1, Patrik Olsson wrote:

Now I see the senor in the frontend and it shows Open or Close depending on the doors state. The icon is a eye, how can I change it?

The so-called badges are designed for numerical values. If there is an "eye", the values has no unit of measurement. Add your door sensor to a group and you will see its state as text.

We are working on the integration of a binary sensor (digital input) right now.

Kind regards,

Fabian  
Reply all
Reply to author
Forward
0 new messages