Home Presence Appdaemon App

@kylerw,

I have edited the app so it will store the database local to the app’s directory. So no need to worry about the app_config['settings'] side of things

Would be interested in seeing how that file is structured and setup if you’re willing to share!

Hello @kylerw,

Here it is, as you noticed nothing special about it. it just helps me to be organised in the way my system runs, and I can easily make adjustments to things, and everything is replicated across my entire system. The app is a dependent to every other app directly or indirectly.

So a change here, means the other apps restarts and they also get all the updates. Simple things like timers or streams. I also sometimes populate things like input_select from here. So instead of editing in HA, and having to reboot, I can modify what my input_select displays by modifying what is in this file. Like my radio stream for living room or bedroom. All input_select for any radio is populated from here, and they all get the same “service”. Then in the app, it does it thing making this simple, so by simply changing this file, I can easily add and remove stream across the home as I like.

settings:
    module: settings
    class: Settings
    priority: 8
    plugin: MQTT

    users:
       Odianosen:
         work_time: 09:00:00
         time_to_prepare: 15

       Nkiruka:
         work_time: 09:00:00
         time_to_prepare: 40
    #  - Henrientta

    home_locations:
      - Living Room
      - Master Bedroom
      - Bedroom 2
      - Kitchen
      - Hallway

    light_settings:
      allocations:
        Control:
            zigbee2mqtt/Master Bedroom Wall Switch|single: light.master_bedroom
            zigbee2mqtt/Hallway Wall Switch|single: light.hallway
            zigbee2mqtt/Bedroom 2 Wall Switch|single: light.bedroom_2
            zigbee2mqtt/Kitchen Wall Switch|left: light.kitchen
            zigbee2mqtt/Kitchen Wall Switch|right: switch.kitchen_fluorescent_light
            zigbee2mqtt/Kitchen Wall Switch|both: group.kitchen_light
            #### feedback ####
            input_number.living_rm_left_hue: light.living_room_left_hue
            input_number.living_rm_right_hue: light.living_room_right_hue
            input_number.master_bedroom_hue: light.master_bedroom_hue
            input_number.bedroom_2_hue: light.bedroom_2
            #### scenses ####
            input_select.living_room_light_scenes: Living Room

        Motion:
            zigbee2mqtt/Hallway Motion Sensor|10: light.hallway
            zigbee2mqtt/Kitchen Outer Motion Sensor|5: light.kitchen:switch.kitchen_fluorescent_light|300
        #   zigbee2mqtt/Kitchen Inner Motion Sensor|5: switch.kitchen_fluorescent_light

        Door Opening:
            zigbee2mqtt/Main Door:
                zigbee2mqtt/Hallway Motion Sensor|20: light.hallway

      steps: 10
      transition: 1
      
    security_settings:
      allocations:
        #### Door Window Sensors ####
        Windows:
            Kitchen Inner Window: Kitchen Inner
            Kitchen Outer Window: Kitchen Outer
            Bedroom 2 Window: Bedroom 2
            Living Room Window: Living Room
            Master Bedroom Window: Master Bedroom
        Doors:
            Main Door: Hallway
        #### Motion Sensors ####
        Motion:
            Hallway Motion Sesnor: light.hallway

    xiaomi_ms:
      - Mobile Switch 1
      
    living_room:
      objects:
        Lamp: switch.standing_lamp
        Socket: switch.living_room_socket
        Kodi: media_player.kodi
        Chromecast: media_player.living_room_chromecast
        Chromecast Audio: media_player.living_room_cast_audio
        Display: switch.power_on_tv
        Sound System: script.lr_sb_power
        Fountain: switch.fountain
        Light: light.living_room
        AV System: switch.av_system_power

    master_bedroom:
      objects:
        Socket: switch.master_bedroom_power
        Media Player: media_player.master_bedroom_player
        Light: light.master_bedroom
        AV System: switch.master_bedroom_av_system

    hallway:
      objects:
        Light: light.hallway

    youtube_id:
        Channels Television: EzzD0Vs0CjI
        Sky News: XOacA3RYrXk
        Bloomberg: Ga3maNZ0x0w
        Al Jazeera: nVHt1_SWTZg
        Kids TV: 
           - EviNZnyn9ic
           - Qi3htOWQC3Q
           - 6rYA9Z9biCE

    radio_streams:
        BBC Radio 1 : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p
        BBC Radio 1xtra : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1xtra_mf_p
        BBC Radio 2 : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p
        BBC Radio 3 : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio3_mf_p
        BBC Radio 4FM : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p
        BBC Radio 4LW : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4lw_mf_p
        BBC Radio 4 Extra : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4extra_mf_p
        BBC Radio 5 Live : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5live_mf_p
        BBC Radio 5 Live Sportsball Extra : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio5extra_mf_p
        BBC Radio 6 Music : http://bbcmedia.ic.llnwd.net/stream/bbcmedia_6music_mf_p
        BBC World Service UK stream : http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-eieuk
        BBC World Service News stream : http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws
        Classic FM : http://media-ice.musicradio.com/ClassicFMMP3
        Capital FM : http://media-the.musicradio.com:80/Capital
        Heart FM : http://media-the.musicradio.com:80/HeartLondon
        Smooth Radio : http://media-the.musicradio.com:80/SmoothLondonMP3
        
    database: /home/pi/.appdaemon/conf/apps/settings/database
    ha_dir: /home/pi/homeassistant/.homeassistant/
1 Like

This is good stuff - may try to adopt this approach. Do you have a repo with your apps/automations? I would be curious to see how this all ties together.

also, I’ve now getting: 2018-09-01 22:09:28.569510 WARNING AppDaemon: home_presence: Entity location.monitor_state not found in AppDaemon

I’m using the default location topic so I’m not sure if that is screwing this up - any thoughts?

@kylerw,

That warning is normal when you try to do something with an entity that doesn’t exist in
Appdaemon.

If like using what I call appdaemon entity, it will warn it doesn’t exist before creating the entity. If it’s an entity within Hass, it will just warn and that’s the end.

I don’t have my automations in any repo I am afraid, so won’t be able to share how it all ties together. But it’s something I am looking to.

Regards

i want to keep track of what is going on here, so i just respond here for that :wink:

but it also gives me the opportunity to say that i like your work and involment in AD @Odianosen25

Its my pleasure @ReneTode, I really appreciate the framework you got no idea.

I have worked as a programmer for top control systems companies like Crestron and Extron like 7 years ago, For the last 6 years I have been involved in designing AV systems, and I have costed thousands of £ in equipment for stuffs that open source projects like AppD can do very great, sometimes better and reliably too. Combining it with HA is an added bonus.

For a while now being a desginer, it has really bugged my mind why ppl should pay so much for automation systems that could easily be achieved by frameworks like this especially in the consumer market. Some might argue “reliability”, but fact is AppD is as stable as the others as even the other manufacturers equipment from time to time have bugs in them.

In terms of stability, this is another point where I like the way @aimc manages releases. Taking his time ensure something is very reliable before any release. I actually just learnt Python last January and AppD was my main reason for learning it as I could see its potential (at least as a side business for me).

Then @aimc came up with the plugin architecture, and my mind went boom. With the power of MQTT for system to system communication, it just blows my mind. I can easily connect two control systems remotely over MQTT using CloudMqtt with ease. The framework in a way is similar to what the new Extron ControlScript does, and to me more powerful. if not anything, the Extron ControlScript though python 3.3, one cannot use open source packages in it as AppD; coupled with the fact the hardware upon which AppD runs will allow me to do other crazy things as its Linux. So to me with the right hardware and plugin, its limitation is endless and that’s what draws me to it.

For me, with the right level of dedication to it, I believe this framework will give the likes of Extron, Crestron, AMX and the others a run for their money in the control space. That’s my 2 cents any way.

Regards

6 Likes

wow, i am glad i wrote here, because a greater way to show your appreciation for AD is hardly possible and i am glad you tagged Andrew also, so he will read it.

i have been his sidekick for over 2 years now and i tell him also how great AD is once in a while, but we all need to hear it from other sides also, from time to time.

and for sure because Andrew has written most of AD just for others.

thx for your kind words

1 Like

I now feel less bad about having the temerity to share my baby coding skills :slight_smile:

1 Like

That’s quite funny @PianSom :sweat_smile:.

I have made some upgrades to the app, based on the recent upgrade by @andrewjfreyer.

There were also some bugs in the code, that didn’t make it function as efficiently as possible, which I have also caught and fixed.

Regards

2 Likes

Great to hear, I was thinking I was going crazy when it started acting up!

Can you provide details on what flags you are using on your pis? Are they both running -t or is one running default?

Hello @kylerw,

Just one runs as default and the rest with the -t flag.

I am honestly still testing and checking a few things, but just felt I should release this for the mean time since this upgrade breaks the code completely.

Do let me know if you find something I might have missed.

Regards

1 Like

Only minor thing I notice is that when the confidence sensors are created, no initial value is sent so they show as unknown (line126ish) - I believe there should be something along the lines of

self.mqtt_send(state_topic, confidence) #send initial confidence

on line 127 or so to initialize that sensor

Thanks for spotting that.

Initially I had the confidence being sent immediately the sensor is created, but found out that it didn’t work as it’s possible HA is still creating it so technically there won’t be a sensor to update.

That’s why on line 154, I have a run in which just waits for like 3 secs before sending the update. You can reduce this time to like 1 and see if there is any difference.

It still sends it, but just after 3 secs.

Regards

Just made some upgrades to the code.

As its normal to have more than a single presence system, its important they are all not scanning before the app sends a scan instruction.

This upgrade will definitely ensure they are all no scanning, regardless of the number of monitor systems in place.

To take full advantage of this, please have only one running the default monitor.sh and the rest using the -t flag.

Regards

1 Like

with the new update to remove owner I suspect you’ll need to make some additional edits. Might I also suggest looking at a way to monitor for beacons (those that are detected as beacons but not known devices)?

1 Like

… sorry @Odianosen25 I made some additional changes that will probably be breaking changes for you too. These will be the last structural ones for a while.

Ok no worries at all.

I can make the changes to the owner’s side of things, but for the beacons I can’t as I don’t have anyone.

Can you send me what the system sends, when it detects the beacons? Or is there a way i can use my phone to simulate it?

No worries @andrewjfreyer, I will make the changes and hopefully no new ones anytime soon :wink:

Regards

1 Like

example beacon response:


0.1.582 03:44:10 pm location/kitchen/C0:97:27:29:D2:A5
{
        retain: false
        version : 0.1.582
        confidence : 100
        name : Unknown
        timestamp : Wed Sep 05 2018 15:44:10 GMT-0600 (MDT)
        manufacturer : SAMSUNG ELECTRO-MECHANICS(THAILAND)
        type : GENERIC_BEACON
        rssi : -61
}

1 Like

:point_up_2: what @kylerw said