From 155725ba3a957014e5b90a7534a8afc1fc1e8dac Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 May 2024 22:20:04 +1200 Subject: [PATCH] weather station esphome and others --- automations/main_sony_tv_automations.yaml | 2 +- configuration.yaml | 15 +- .../__pycache__/ts0601_smoke.cpython-312.pyc | Bin 0 -> 7458 bytes .../ts0601_valve_garden.cpython-312.pyc | Bin 0 -> 4678 bytes custom_zha_quirks/ts0601_smoke.py | 174 ++++ custom_zha_quirks/ts0601_valve_garden.py | 149 +++ esphome/esp-attobat.yaml | 112 ++- esphome/esp-mainovenmonitor.yaml | 114 ++- .../esp-mmwave-office-7776ec copy.yaml.old | 370 ++++++++ esphome/esp-occupancyoffice.yaml | 437 +++++++++ esphome/esp-occupancystair.yaml | 404 +++++++++ ...tcupfan2.yaml => esp-ranchsliderfans.yaml} | 15 +- esphome/esp-weatherstation.yaml | 855 ++++++++++++++++++ esphome/esphome-web-7776ec copy.yaml.old | 381 ++++++++ esphome/trash/esp-mmwave-office-7776ec.yaml | 370 ++++++++ esphome/trash/esp-mmwave-office.yaml | 31 + esphome/trash/esp-mmwaveoffice-7776ec.yaml | 401 ++++++++ esphome/trash/esphome-web-7776ec.yaml | 393 ++++++++ packages/covid_count.yaml | 55 -- packages/ev_charging.yaml | 42 +- packages/foxhole_controls.yaml | 4 + packages/google_keep.yaml | 7 - packages/mqtt_statestream.yaml | 12 + packages/office_media_buttons.yaml | 74 +- packages/pool_controls.yaml | 8 + packages/presense_sense.yaml | 21 + packages/security_and_notifications.yaml | 7 + packages/shower_controls.yaml | 7 + packages/tautulli.yaml | 5 + packages/waste_collection.yaml | 50 + scripts/check_config.yaml | 6 +- scripts/zha.yaml | 2 + 32 files changed, 4341 insertions(+), 182 deletions(-) create mode 100644 custom_zha_quirks/__pycache__/ts0601_smoke.cpython-312.pyc create mode 100644 custom_zha_quirks/__pycache__/ts0601_valve_garden.cpython-312.pyc create mode 100644 custom_zha_quirks/ts0601_smoke.py create mode 100644 custom_zha_quirks/ts0601_valve_garden.py create mode 100644 esphome/esp-mmwave-office-7776ec copy.yaml.old create mode 100644 esphome/esp-occupancyoffice.yaml create mode 100644 esphome/esp-occupancystair.yaml rename esphome/{esp-netcupfan2.yaml => esp-ranchsliderfans.yaml} (87%) create mode 100644 esphome/esp-weatherstation.yaml create mode 100644 esphome/esphome-web-7776ec copy.yaml.old create mode 100644 esphome/trash/esp-mmwave-office-7776ec.yaml create mode 100644 esphome/trash/esp-mmwave-office.yaml create mode 100644 esphome/trash/esp-mmwaveoffice-7776ec.yaml create mode 100644 esphome/trash/esphome-web-7776ec.yaml delete mode 100644 packages/covid_count.yaml create mode 100644 packages/foxhole_controls.yaml delete mode 100644 packages/google_keep.yaml create mode 100644 packages/mqtt_statestream.yaml create mode 100644 packages/security_and_notifications.yaml create mode 100644 packages/shower_controls.yaml create mode 100644 packages/tautulli.yaml create mode 100644 scripts/zha.yaml diff --git a/automations/main_sony_tv_automations.yaml b/automations/main_sony_tv_automations.yaml index 587ea76..f0559e5 100644 --- a/automations/main_sony_tv_automations.yaml +++ b/automations/main_sony_tv_automations.yaml @@ -9,6 +9,6 @@ action: - type: turn_off device_id: 4a9f71fc64e158f1c9286d6e43ce782e - entity_id: remote.sony_kd_55x85k + entity_id: remote.lounge_tv domain: remote mode: single diff --git a/configuration.yaml b/configuration.yaml index 1361e15..79631d9 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -29,16 +29,9 @@ logger: custom_components.evnex: debug evnex: debug +zha: + enable_quirks: true + custom_quirks_path: /config/custom_zha_quirks/ + device_tracker: - platform: bluetooth_le_tracker - -input_boolean: - foxhole_occupied: - name: Foxhole Guest Occupied - icon: mdi:briefcase-plus-outline - quiet_time: - name: Quiet time for no notifications - icon: mdi:shield-moon - away_occupied_routine: - name: Automation for Lights etc when away - icon: mdi:shield-lock diff --git a/custom_zha_quirks/__pycache__/ts0601_smoke.cpython-312.pyc b/custom_zha_quirks/__pycache__/ts0601_smoke.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..430b37fdf7fd48f64f0928e2b440667563a67be3 GIT binary patch literal 7458 zcmd5>U2GfIm7d}6h#XRsL|L-_JW}*yx;7=nRxK-qH?%}MiX~AI>2^IvGfQ)>q>=ff z%nU6{P`2J8z}moe17mk#clV*jZXe?Mp-x*Mekc}s%wivw<2oRBkN^v`FMd-X1upuu z=iK2?vP`vg(T5JiGxwfz@16T|&Uena`tLx%$H4RSX_GDXfVKGe0-fU~`ka#H9Cbs3;#rE7`@o=s~?8tSBow+Wti?-pi z-MJpICwD|Vk`qKB*DLn2jDsQU%9Oo;-8XsdA*=x(v0rWw2V|c(DEq}B2Xldu`41R5 zK!k_RYKxTw~J9Qo$RsIaIOa)Oi+=eOv}mS~8&-6Z8y+1Q8H2y^Z=M_*Ju`CVOmtb#W&h}2 zW2aspIXO0V+UoTT7d;nYO@6Yd>4n@BxvpeL#A~|Gr8OmEdM>Di;;Lpk6MEY8Br_yW zG}Dz*a>VqXQ}StbeLBBd)S;5rb)v2(l??);d8gBwSjc11d9J9zc>byQx2GrLQtI-2 z+-!)?P0c5!=Tb>CI6XIiDJ4zLTuP?m3rW*Io0y8vB&F%O^9i#taVhnJ)HlD7I6plT zm!_x81~D;bjTdp5p;U1_JyXb}vy)j^2vIH0Y&u_Dv^gEvW-lkE>#B0KsKb)FQ8r&# zBkE)!zo;w~)wHe@^3|>i3(BFmK(~}2lrom4Sd^<)wr@h=@4e=T?bI zWZK50>Gm+7mSZ)6t zvOCW~%|rPP*$cbFz3+O3d3M<&@4oBKvtiS9tF{Z`t<>Gw9pxXO|A> z-EYfx-_UY!w`P|%*@vKo_~1E4{BtTQqZul$%4wZQpxYK!nEnj_wyKhw0mNpK*QM*} zY>_;}5uV|3JOiC&p2;{u%`P&_>HHGeh+Y}FF)(uK#>9X&VU@ls6!RdHvqTnZ-6}czjS%=PuQZdma3Q{6de_owUdb<+&ivXn({ImCQe@MY zvA`V45s&H8NOsZm&>fOZH{Eg5W1)@d!m-T;Ny=o?nkGpaf`ow2&EG|aGZfT^Gt|dP z8_Q|wy`rLC(}r~o9kE2gExNj{4nePtV+TQK^raIx4ed2_48Og}e8B~7dkwDl{@_Og zPq~qbzv*e~i6{OOm6PL-V?Uet=kJtThm6*ta_jJu*5OY_Z=J93p$}(o&z5CgGAl|akWw&5p%;eCzA41TQ4PZ|7FCDeC6@r%^sfuCRb z+UW=cw>(TR{Io6lBoM8%ci(UNSKpn{kI198q`5V6F!^G`GCG=(`6uuj{6DWuJjZl9%bkqnPt+66TD1w#7JB^jlp|Aa(KyVv2 zgNg7aCrSBqj!2T}lcZchE@rXJOR(wbY*pfwB)O20Boz(CWOdV91eF|@bafaQ>g&k$ z)r>)-2V(}R$D1M9tRy{P)w9q{LwkEu{VVK-s7Of^1v5Z?`vLR6t~l&TLvQJ|laJo{ z{wR`V-}2<cjh}|L+sPh82BXSS+Z*Td^qZw?HyPxeo0tEYYkO z^gxBDeKNSi_Ja`D2*2&`1EH?GCcO9_7LD;Yc6~b zubwkU7~A)3G7qa?1fXUgI5ynVc}0)TMLa6PI%=N+3{b6aKvg}CYOUM+Mm0e?(r=Kh^6${`vs-94{-ZGL9##StrvsI z4m8es5g75-i?@iY?kLWKMuAYeeh>G7JvPX&UN7}()* zeY>k>L4P*OGkM!(YLHl&A-e`ZN=^G2jZs={HX?v5T`y$y^b&c7Ryr5))zz^!keSW9 z_$pmprA$23H(*IhXMj0V<`M>%D7~|=hd*y{@07We!KF&y{%Zi9RP-FiA&7;YPyLPyYs*SzSpYX-fxb+~UsLpDE90vsasq}@ zBr5zVF2eN7M9ZkkDrU_ajW5id$fh5%PVhRCPHyNXXGwt_fJyHWxF@qDt^Or@8x;|> z>S!#$MKra1%m|heNalfPb-YMdox`qq6U>PJXm5gkq|BW)xU-M-&$%gTC{FR>pV+vR@G;7*sh z34@z>e1Tdvx)ZMLGh(n#9E;DU;| z;zn2X@|H>j>p~0yY?@F;>x0+d!ct!hl^<3YzsX3o@L8{w_DDhbt*5TkS(Bof(}xD( zpz?cz@O9P(F1(4P(XfhvtBS`!qh<>d=Al{-xO(dDL=C#$$8MOhVIbVr@lVBDu7BXa z=BUOL;n%SQg1awwxi@|#5r-MFZox;SBDq>vQPXhQY;CjJ2jfPL z)D2>2#2W&+ieRCl?VIimWodQYvEgM)4t?vY#}Ah&s@5o zVw|KRT&v?qFu_sr!cv9*lrU-&5=>2040+84Ox|KLrV{GBcj-s({_x#$_ps4DT<)GQx+luraicq43H4OMhs)u9 zBivsJca*~eMtERPp}!m+Hp0VO4es9NEuLu-D&h9Ki93l(xb5!Tow+Tyv#)upB@ha3 zIUB>it%h)u=jQZQ^wlRbX>?Eip~)PngpXIk$135Wtws*!(|o{u4u^0)%`hKlxW)6q zMXEw{A0sDd0%dx$g{39DQEH~j5Vdt7imH&u!{IG~bqS=R6~VP0Do#{~Y)doU^rgm8 z&|wKSGTCVLI!cRL>2}uA8mcg;9G2ElU7=o=#?hU1x@#m;R3S6Bvb+YER&^$5o@QgM z4*&DXYdY0lOU0?GQjMo-i5gGSMKieDM+ekW(dSwEi~JOt)738|1x-1oMF3ao@7;bK)1K zk#@uesEW943ba7-p|uPIZ~_#l1E)apsXwA$MC1eM1p)*J3RFOW(vSiN`O?nrk$Q#A z1MNzjot>F|&1>iW*4gPr&@vlU{B!`J&)J~W z0;5TWWI9zR$DM|3x>Og(9fsTVs9uiCMu(}W3ddbWr|DCDW|!J!`c=OfPy=RA4Vv9* zH|M*JklCa5n7wMR*{AlIC)5*WzuIpOr~{nuF$T>cb%^6$W7r%~N6b-m)C{X(b4(pG zPpT))Q|c*mTpc$j)CmDO5Ej;Bt&1J>`1C`#8*A#*4z!5$jyp(K@DLt*C^hL3PVWS| z51)J}HmQ@G+67cUcI{KoY&ar;N_VonkqX~R8Mkm)$G386Y(;n2ym&;Q(tIvmf?llL zOhKp2m90|2oabUN_GSv@yq+rM3i*gkomWy;E=}b{QYaTKDke%P8eA#d#$>LL&*ZXY z!X>G^n#Or-Q7M@-G0f|jUwCC{Zb3`_bY+2h7UJ_OiKTdQmHL+AD{Dz@F1EIsT)4hU zJC+mk3$aygDSkCUyAo^3BV6yw^~BYs*n+k+4=3x17nW1`awe57l?fccfP-TaansQJ zO0sadR3f<>_6^primi90u>{G3#IQ23zOxP%5>SuTi-@*pmrbG$`^)brw+*(W8 z!^VkxB9oyV`)GWb4zt16_0XJ_wrym?rg_n>AI5hPM&P_ib?AaBg0VyzWJ?`BM0~k2 z&1m7n#BkcaZuoYtbTfQZ6HD{actoOZP0OcDtZCG%X=Xt$8w^)8?X_~sXmVVdrWewh z_5s>ur~7JpD$VUUmF8Zcflq*Vj{MA;Dp}L#r)MIW0{0LS#cO_)vMsbPSEJA+=q@(SD6%`?sGf{SR}U-)U~3?U_5jZLaQnS5||# z8;7trLZAZ1)g2WG4mhwF-}yIic60#bB!CYDD!gv7 zCBkGJ;8*S!jg)yqPhG5xuseM1YS9*d9;7W6CY$KJz zkSGJ}P-Ggwp+k|gF#fjlEU-Dv^IU!)zQ6d9SUok{JWoUITF1L{LNOiepXy*rqJ3EiU@4_y+ntnC%Ur#3XrJZ&fNS0`%+d zLxU#zq41EM722C%_MgM9e{|dxf9-UF`JY3-ll~&!79wJ0A^~c+O>!k1E)~L=0$e(L z)KLpMj)K=IhpF+1lRB+3=!p9H5{F^r`XaAuwb*+z@xwX6?!C1eij(5 z1tzP3$y#8l8kqVdFthnmUGmkWo~qRISZG8mN@Rb{-cgzBM@yNP!adoD@wKK63vNKH9YRnF9vL15NG zU$D& zI=zn(0J~OUdQQV{zqP84-3OrfqlFrlbVpXePF=(@cC9lnJl3!q=xyqcb>?En8t%Z# zI`g_?4g1xC*&Mzh~MqM-GP;Q$J+nr4!9Th;S*Wc z_dc}z-%9)o!n?YB`Fc`YiLEUX_Ph}nmuMF2T23eI6(Ai9 z@aTq5Ttt}v5Dx(Av2xjbiha*eB@x#WSFdWZrNwJWo|NobnNIleV$7ek>Pzy~|LlcLPNG)`(8amhTILCqw1qH(IjsJP-{i%;;|9bJ` zi`!#Y8r@#Mui@zmc^l4PK;B$xOd?OPu5=#S=R$S(!nf{I4~^DCPt`*+jV?EA6>PIr zp8{KnKG;h1cgw$g*$!r=gUAnf=BF;Bkj=6$Kp6@$=s0h?k(~Bi)P`JW7n3Pb$Tk$;v-QFd~X+eHl`2s=5?f)OZ CTtHR; literal 0 HcmV?d00001 diff --git a/custom_zha_quirks/ts0601_smoke.py b/custom_zha_quirks/ts0601_smoke.py new file mode 100644 index 0000000..50c1fb5 --- /dev/null +++ b/custom_zha_quirks/ts0601_smoke.py @@ -0,0 +1,174 @@ +""" +DY-YG400A Smoke Sensor, TS0601 from _TZE204_ntcy3xu1 +https://www.aliexpress.com/item/1005005863519099.html +https://www.aliexpress.com/item/1005005854203557.html +""" + +import logging + +import zigpy.profiles.zha +from zigpy.quirks import CustomDevice +import zigpy.types as t +from zigpy.zcl.clusters.general import ( + Basic, + Groups, + Ota, + Scenes, + Time, + BinaryInput, + BatterySize, +) +from zigpy.zcl.clusters.security import IasZone +from zhaquirks import Bus +from zhaquirks.const import ( + DEVICE_TYPE, + ENDPOINTS, + INPUT_CLUSTERS, + MODELS_INFO, + OUTPUT_CLUSTERS, + PROFILE_ID, + ZONE_TYPE, +) +from zhaquirks.tuya import ( + TuyaLocalCluster, + TuyaManufCluster, + TuyaManufClusterAttributes, + TuyaPowerConfigurationCluster, +) + +_LOGGER = logging.getLogger(__name__) + +TUYA_SMOKE_DETECTED_ATTR = 0x0401 # [0]/[1] [Detected]/[Clear]! +TUYA_SMOKE_TAMPERED_ATTR = 0x0104 # [0]/[1] [Clear]/[Tampered]! +TUYA_SMOKE_BATTERY_ATTR = 0x040e # [0]/[1]/[2] [Low]/[Med]]/[Full]! + + +class TuyaSmokeDetectorCluster(TuyaManufClusterAttributes): + """Manufacturer Specific Cluster of the TS0601 smoke detector.""" + + attributes = { + TUYA_SMOKE_DETECTED_ATTR: ("smoke_detected", t.uint8_t, True), + TUYA_SMOKE_TAMPERED_ATTR: ("tampered_device", t.uint8_t, True), + TUYA_SMOKE_BATTERY_ATTR: ("battery_status", t.uint8_t, True), + } + + def _update_attribute(self, attrid, value): + super()._update_attribute(attrid, value) + if attrid == TUYA_SMOKE_DETECTED_ATTR: + status = IasZone.ZoneStatus.Alarm_1 if value == 0 else 0 + self.endpoint.device.ias_bus.listener_event("update_attribute", "zone_status", status) + elif attrid == TUYA_SMOKE_TAMPERED_ATTR: + self.endpoint.device.tamper_detection_bus.listener_event( + "update_attribute", "present_value", bool(value) + ) + elif attrid == TUYA_SMOKE_BATTERY_ATTR: + batt = 5 if value == 0 else 40 if value == 1 else 100 + self.endpoint.device.battery_bus.listener_event("battery_change", batt) + else: + _LOGGER.warning( + "[0x%04x:%s:0x%04x] unhandled attribute: 0x%04x", + self.endpoint.device.nwk, + self.endpoint.endpoint_id, + self.cluster_id, + attrid, + ) + + +class TuyaIasZone(TuyaLocalCluster, IasZone): + """ + IAS Zone: this generates the "Smoke" entity for HA. + Receives updates from TuyaSmokeDetectorCluster. + """ + + _CONSTANT_ATTRIBUTES = {ZONE_TYPE: IasZone.ZoneType.Fire_Sensor} + + def __init__(self, *args, **kwargs): + """Init.""" + super().__init__(*args, **kwargs) + self.endpoint.device.ias_bus.add_listener(self) + + +class TuyaPowerConfigCluster(TuyaPowerConfigurationCluster): + """ + Power Config Cluster: this generates the "Battery" entity for HA. + Receives updates from TuyaSmokeDetectorCluster. + """ + + _CONSTANT_ATTRIBUTES = { + TuyaPowerConfigurationCluster.attributes_by_name["battery_size"].id: BatterySize.AAA, + TuyaPowerConfigurationCluster.attributes_by_name["battery_quantity"].id: 2, + TuyaPowerConfigurationCluster.attributes_by_name["battery_rated_voltage"].id: 15, + } + + +class TuyaTamperDetection(TuyaLocalCluster, BinaryInput): + """ + Tamper Detection Cluster: this generates the "Binary input" entity for HA, which is updated + with the Tampered state. Receives updates from TuyaSmokeDetectorCluster. + """ + + _CONSTANT_ATTRIBUTES = { + BinaryInput.attributes_by_name["description"].id: "Tamper Detected", + BinaryInput.attributes_by_name["active_text"].id: "Tampered", + BinaryInput.attributes_by_name["inactive_text"].id: "Clear", + } + + def __init__(self, *args, **kwargs): + """Init.""" + super().__init__(*args, **kwargs) + self.endpoint.device.tamper_detection_bus.add_listener(self) + + +class TuyaSmokeDetector0601(CustomDevice): + """TS0601 Smoke detector quirk.""" + + def __init__(self, *args, **kwargs): + """Init.""" + self.ias_bus = Bus() + self.battery_bus = Bus() + self.tamper_detection_bus = Bus() + super().__init__(*args, **kwargs) + + signature = { + MODELS_INFO: [ + ("_TZE200_uebojraa", "TS0601"), + ], + ENDPOINTS: { + 1: { + PROFILE_ID: zigpy.profiles.zha.PROFILE_ID, + DEVICE_TYPE: zigpy.profiles.zha.DeviceType.SMART_PLUG, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + TuyaManufCluster.cluster_id, + ], + OUTPUT_CLUSTERS: [ + Time.cluster_id, + Ota.cluster_id, + ], + }, + }, + } + + replacement = { + ENDPOINTS: { + 1: { + PROFILE_ID: zigpy.profiles.zha.PROFILE_ID, + DEVICE_TYPE: zigpy.profiles.zha.DeviceType.IAS_ZONE, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + TuyaIasZone, + TuyaSmokeDetectorCluster, + TuyaPowerConfigCluster, + TuyaTamperDetection, + ], + OUTPUT_CLUSTERS: [ + Time.cluster_id, + Ota.cluster_id, + ], + }, + }, + } \ No newline at end of file diff --git a/custom_zha_quirks/ts0601_valve_garden.py b/custom_zha_quirks/ts0601_valve_garden.py new file mode 100644 index 0000000..02f86a2 --- /dev/null +++ b/custom_zha_quirks/ts0601_valve_garden.py @@ -0,0 +1,149 @@ +"""Tuya valve devices.""" + +import logging +from typing import Dict + +from zigpy.profiles import zha +from zigpy.quirks import CustomDevice +import zigpy.types as t +from zigpy.zcl import foundation +from zigpy.zcl.clusters.general import ( + Basic, + Groups, + Ota, + PowerConfiguration, + Scenes, + Time, +) + +from zhaquirks.const import ( + DEVICE_TYPE, + ENDPOINTS, + INPUT_CLUSTERS, + MODELS_INFO, + OUTPUT_CLUSTERS, + PROFILE_ID, +) +from zhaquirks.tuya import NoManufacturerCluster +from zhaquirks.tuya.mcu import ( + DPToAttributeMapping, + TuyaAttributesCluster, + TuyaDPType, + TuyaLevelControl, + TuyaMCUCluster, + TuyaOnOff, + TuyaOnOffNM, + TuyaPowerConfigurationCluster, +) + +_LOGGER = logging.getLogger(__name__) + + +class TuyaLevelControlNM(NoManufacturerCluster, TuyaLevelControl): + """Tuya LevelControl cluster with NoManufacturerID.""" + + +class TuyaValveManufCluster(TuyaMCUCluster): + """Tuya valve manufacturer cluster.""" + + attributes = TuyaMCUCluster.attributes.copy() + attributes.update( + { + 0xEF03: ("dp_3", t.uint32_t, True), + 0xEF65: ("dp_101", t.uint32_t, True), + 0xEF66: ("dp_102", t.uint32_t, True), # <-- new cluster attribute with fake IDs (102=0x66).Format= ID: ("name", type, True) + } + ) + + dp_to_attribute: Dict[int, DPToAttributeMapping] = { + 2: DPToAttributeMapping( + TuyaOnOffNM.ep_attribute, + "on_off", + dp_type=TuyaDPType.BOOL, + ), + 1: DPToAttributeMapping( + TuyaLevelControlNM.ep_attribute, + "current_level", + dp_type=TuyaDPType.VALUE, + converter=lambda x: (x * 255) // 100, + dp_converter=lambda x: (x * 100) // 255, + ), + 3: DPToAttributeMapping( + TuyaMCUCluster.ep_attribute, + "dp_3", + dp_type=TuyaDPType.VALUE, + ), + 101: DPToAttributeMapping( + TuyaMCUCluster.ep_attribute, + "dp_101", + dp_type=TuyaDPType.VALUE, + ), + 102: DPToAttributeMapping( # <-- device DP102 + TuyaMCUCluster.ep_attribute, # <-- reference to the cluster which has the attribute + "dp_102", # <-- attribute "name" + dp_type=TuyaDPType.VALUE, # <-- DP Type it is related to the attribute type + ), + 108: DPToAttributeMapping( + TuyaPowerConfigurationCluster.ep_attribute, + "battery_percentage_remaining", + dp_type=TuyaDPType.VALUE, + ), + } + + data_point_handlers = { + 2: "_dp_2_attr_update", + 1: "_dp_2_attr_update", + 3: "_dp_2_attr_update", + 101: "_dp_2_attr_update", + 102: "_dp_2_attr_update", + 108: "_dp_2_attr_update", + } + + async def write_attributes(self, attributes, manufacturer=None): + """Overwrite to force manufacturer code.""" + + return await super().write_attributes( + attributes, manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID + ) + + +class TuyaValve(CustomDevice): + """Tuya valve device.""" + + signature = { + MODELS_INFO: [("_TZE200_sh1btabb", "TS0601")], + ENDPOINTS: { + # + 1: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.SMART_PLUG, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + TuyaValveManufCluster.cluster_id, + ], + OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], + } + }, + } + + replacement = { + ENDPOINTS: { + 1: { + DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + TuyaValveManufCluster, + TuyaOnOffNM, + TuyaLevelControlNM, + TuyaPowerConfigurationCluster, + ], + OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id], + } + } + } diff --git a/esphome/esp-attobat.yaml b/esphome/esp-attobat.yaml index dde9492..2d46e79 100644 --- a/esphome/esp-attobat.yaml +++ b/esphome/esp-attobat.yaml @@ -1,82 +1,115 @@ ############################################# -# Common -############################################# -substitutions: - devicename: esp-attobat - nice_devicename: "Atto Battery Monitor" +############################################# +# BYD ATTO3 12V Battery Monitor +# Monitoring the status of a vehicle 12V battery with +# an esp8266 (D1 Mini). It will obviously only +# transmit when the vehicle is within wifi range. +# Voltage is measured with a resistor voltage divider +# into the analogue GPIO on the esp8266. +# https://zorruno.com/2022/vehicle-12v-battery-monitoring/ +############################################## +############################################# +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esp-attobat" + friendly_name: "Atto3 12V Battery Monitor" + description_comment: "Atto3 12V Battery Monitor (when home)" + api_key: !secret esp-attobat_api_key #unfortunately you can't use substitutions in secrets names + ota_pass: !secret esp-attobat_ota_pass #unfortunately you can't use substitutions in secrets names + mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like + update_time: 30s #update time for for temp sensors etc + #Add these if we are giving it a static ip, or remove them in the Wifi section + static_ip_address: !secret esp-attobat_static_ip + static_ip_gateway: !secret esp-attobat_gateway + static_ip_subnet: !secret esp-attobat_subnet ############################################# # ESPHome ############################################# esphome: name: $devicename + comment: ${description_comment} #appears on the esphome page in HA -######################################## -# Specific board for ESPHome device -######################################## +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp8266.html +# https://esphome.io/components/esp32.html +############################################# esp8266: board: d1_mini + framework: + version: latest #recommended, latest or dev ############################################# # ESPHome Logging Enable -############################################# +# https://esphome.io/components/logger.html +############################################# logger: + level: INFO #INFO Level suggested, or DEBUG for testing + #baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 -######################################## +############################################# # Enable the Home Assistant API -######################################## +# https://esphome.io/components/api.html +############################################# api: encryption: - key: !secret esp-attobat_api_key + key: ${api_key} -######################################## +############################################# # Enable Over the Air Update Capability -# Safe mode will detect boot loops -######################################## +# https://esphome.io/components/ota.html?highlight=ota +############################################# ota: - safe_mode: true - password: !secret esp-attobat_ota_pass + safe_mode: true #Safe mode will detect boot loops + password: ${ota_pass} -######################################## -# Use Wifi -# (credentials are in secrets file) -######################################## +############################################# +# Wifi Settings +# https://esphome.io/components/wifi.html +############################################# wifi: ssid: !secret wifi_ssid password: !secret wifi_password - # Details for fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Esp-attobat2 Fallback Hotspot" - password: !secret fallback_ap_password + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode # Static IP (for lower power/quicker on time) manual_ip: - static_ip: !secret esp-attobat_static_ip - gateway: !secret esp-attobat_gateway - subnet: !secret esp-attobat_subnet + static_ip: ${static_ip_address} + gateway: ${static_ip_gateway} + subnet: ${static_ip_subnet} + ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode + ssid: ${devicename} fallback AP + password: !secret fallback_ap_password + ap_timeout: 5min #default is 1min +captive_portal: # Fallback captive portal https://esphome.io/components/captive_portal.html ############################################# -# Fallback captive portal -############################################# -captive_portal: - -######################################## # Web Portal for display and monitoring -######################################## +############################################# web_server: port: 80 + version: 2 + include_internal: true + ota: false auth: username: !secret web_server_username password: !secret web_server_password -######################################## +############################################# # MQTT Monitoring -######################################## +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# mqtt: broker: !secret mqtt_server - topic_prefix: esphome/esp-attobat - username: !secret mqtt_username - password: !secret mqtt_password + topic_prefix: ${mqtt_topic}/${devicename} + #username: !secret mqtt_username + #password: !secret mqtt_password # # Availability Topic #birth_message: @@ -98,6 +131,7 @@ mqtt: ######################################## # Deep Sleep +# https://esphome.io/components/deep_sleep.html ######################################## deep_sleep: run_duration: 20s diff --git a/esphome/esp-mainovenmonitor.yaml b/esphome/esp-mainovenmonitor.yaml index 6a3d615..66baa6d 100644 --- a/esphome/esp-mainovenmonitor.yaml +++ b/esphome/esp-mainovenmonitor.yaml @@ -1,75 +1,117 @@ +############################################# +############################################# +# OVEN POWER MONITOR +# Monitoring power of an oven (at the main +# switchboard) using a sonoff basic (esp8266) +# and a PZEM-004T. The relay also allows disabling +# of the oven with a contactor (eg on smoke detection) +# https://zorruno.com/2022/nodered-oven-notifications/ +############################################## +############################################# + +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esp-mainovenmonitor" + friendly_name: "esp-mainovenmonitor" + description_comment: "Oven power monitoring and disable, with a sonoff basic" + api_key: !secret esp-mainovenmonitor_api_key #unfortunately you can't use substitutions in secrets names + ota_pass: !secret esp-mainovenmonitor_ota_pass #unfortunately you can't use substitutions in secrets names + mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like + #update_time: 30s #update time for for temp sensors etc + ############################################# # ESPHome ############################################# esphome: - name: "esp-mainovenmonitor" + name: ${devicename} + comment: ${description_comment} #appears on the esphome page in HA -############################################# -# Specific board for ESPHome device -############################################# +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp8266.html +# https://esphome.io/components/esp32.html +############################################# esp8266: - board: sonoff_basic + #board: sonoff_basic + #board: esp01_1m + board: esp8285 + framework: + version: latest #recommended, latest or dev +#esp32: +# board: nodemcu-32s +# framework: +# type: arduino +# #type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. +# version: recommended #recommended, latest or dev ############################################# # ESPHome Logging Enable +# https://esphome.io/components/logger.html ############################################# -# NOTE: Baudrate set to 0 as we are using the UART with PZEM logger: - baud_rate: 0 + level: INFO #INFO Level suggested, or DEBUG for testing + baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 ############################################# # Enable the Home Assistant API +# https://esphome.io/components/api.html ############################################# api: encryption: - key: !secret esp-mainovenmonitor_api_key + key: ${api_key} ############################################# # Enable Over the Air Update Capability -# Safe mode will detect boot loops +# https://esphome.io/components/ota.html?highlight=ota ############################################# ota: - safe_mode: true - password: !secret esp-mainovenmonitor_ota_pass + safe_mode: true #Safe mode will detect boot loops + password: ${ota_pass} ############################################# -# Use Wifi +# Wifi Settings +# https://esphome.io/components/wifi.html ############################################# wifi: ssid: !secret wifi_ssid password: !secret wifi_password - # Details for fallback hotspot (captive portal) - # in case wifi connection fails - ap: - ssid: "Mainovenmonitor Fallback Hotspot" + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: #optional static IP address + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode + ssid: $devicename fallback AP password: !secret fallback_ap_password -# manual_ip: -# static_ip: 192.168.x.x -# gateway: 192.168.X.x -# subnet: 255.255.255.0 - -############################################# -# Fallback captive portal -############################################# -captive_portal: + ap_timeout: 5min #default is 1min +captive_portal: # Fallback captive portal https://esphome.io/components/captive_portal.html ############################################# # Web Portal for display and monitoring ############################################# web_server: port: 80 - auth: - username: !secret web_server_username - password: !secret web_server_password + version: 2 + include_internal: true + ota: false +# auth: +# username: !secret web_server_username +# password: !secret web_server_password -############################################# +############################################# # MQTT Monitoring -############################################# +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# mqtt: broker: !secret mqtt_server - topic_prefix: esphome/esp-mainovenmonitor - username: !secret mqtt_username - password: !secret mqtt_password + topic_prefix: ${mqtt_topic}/${devicename} + #username: !secret mqtt_username + #password: !secret mqtt_password ############################################# @@ -116,9 +158,9 @@ switch: name: "Main Oven Disable" pin: GPIO12 -#button: -# - platform: restart -# name: "Main Oven ESPHome Restart" +button: + - platform: restart + name: "Main Oven ESPHome Restart" # LED Flashes on errors or warnings diff --git a/esphome/esp-mmwave-office-7776ec copy.yaml.old b/esphome/esp-mmwave-office-7776ec copy.yaml.old new file mode 100644 index 0000000..79d55a4 --- /dev/null +++ b/esphome/esp-mmwave-office-7776ec copy.yaml.old @@ -0,0 +1,370 @@ +# https://digiblur.com/2023/05/24/esphome-mmwave-presence-how-to-guide/ + +substitutions: + name: esp-mmwave-office-7776ec + friendly_name: esp-mmwave-office + update_time: 30s + +esphome: + name: ${name} + friendly_name: ${friendly_name} + name_add_mac_suffix: false + #project: + #name: esphome.web + #version: '1.0' + on_boot: #LD1125H Initial Setting + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + + + +############################################# +# ESPHome Logging Enable +############################################# +# NOTE: Baudrate set to 0 as we are using the UART with PZEM +logger: + level: INFO #You Can Use "INFO" Level + baud_rate: 0 + +############################################# +# Enable the Home Assistant API +############################################# +api: + #encryption: + # key: !secret esp-mainovenmonitor_api_key + +############################################# +# Enable Over the Air Update Capability +# Safe mode will detect boot loops +############################################# +ota: + # safe_mode: true + # password: !secret esp-mainovenmonitor_ota_pass + +############################################# +# Use Wifi +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + power_save_mode: LIGHT + # Details for fallback hotspot (captive portal) + # in case wifi connection fails + ap: + ssid: "MMwave Office Fallback Hotspot" + password: !secret fallback_ap_password +# manual_ip: +# static_ip: 192.168.x.x +# gateway: 192.168.X.x +# subnet: 255.255.255.0 + + +# Allow provisioning Wi-Fi via serial +#improv_serial: + +############################################# +# Fallback captive portal +############################################# +# In combination with the `ap` this allows the user +# to provision wifi credentials to the device via WiFi AP. +captive_portal: + +#dashboard_import: +# package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main +# import_full_config: true + +# Sets up Bluetooth LE (Only on ESP32) to allow the user +# to provision wifi credentials to the device. +##esp32_improv: +## authorizer: none + +############################################# +# Web Portal for display and monitoring +############################################# +#web_server: +# port: 80 +# auth: +# username: !secret web_server_username +# password: !secret web_server_password + + +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + +#esp32: +# board: esp32dev +# framework: +# type: arduino +esp32: + board: nodemcu-32s + framework: + type: esp-idf #Suggest Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] + + +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" +status_led: + pin: + number: GPIO2 #ESP32 OnBroad LED + inverted: false +#web_server: #Avoid Using Web Server To Prevent Hang +# port: 80 +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } +number: + - platform: template + name: ${upper_devicename} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${upper_devicename} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${upper_devicename} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${upper_devicename} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 +sensor: + - platform: bme280_i2c + temperature: + name: ${upper_devicename} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${upper_devicename} BME280 Pressure + oversampling: 2x + humidity: + name: ${upper_devicename} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} +# - platform: aht10 +# temperature: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Temp +# humidity: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Humidity +# update_interval: ${update_time} +# - platform: wifi_signal +# name: ${upper_devicename} WiFi Signal +# update_interval: 60s + - platform: uptime + name: ${upper_devicename} Uptime + - platform: template + name: ${upper_devicename} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${upper_devicename} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${upper_devicename} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" +binary_sensor: + - platform: status + name: ${upper_devicename} Status + - platform: template + name: ${upper_devicename} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${upper_devicename} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/esphome/esp-occupancyoffice.yaml b/esphome/esp-occupancyoffice.yaml new file mode 100644 index 0000000..d413efd --- /dev/null +++ b/esphome/esp-occupancyoffice.yaml @@ -0,0 +1,437 @@ + +############################################# +############################################# +# HiLink LD1125H mmWave sensor, with BME280 Temp/Hum/Pres Sensor on an ESP32 +# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/tree/main +# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/blob/main/LD1125H/ESP32-LD1125H-Complete.yaml +# +# mth1: 0 to 2.8m sensitive +# mth2: 2.8 to 8m sensitive +# mth3: above 8m sensitive +# rmax: max distance +# Clearance Time: Mov/Occ to Clearance waiting time +# Movement Time: Mov to Occ waiting time +# +############################################# +############################################# + +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esp-occupancyoffice" + friendly_name: "Office State" + description_comment: "D1 Mini ESP32 with LD1125H mmWave and environment sensors for downstairs office" + api_key: !secret esp-occupancyoffice_api_key #unfortunately you can't use substitutions in secrets names + ota_pass: !secret esp-occupancyoffice_ota_pass #unfortunately you can't use substitutions in secrets names + mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like + update_time: 30s #update time for for temp sensors etc + +############################################# +# ESPHome +# https://esphome.io/components/esphome.html +############################################# +esphome: + name: ${devicename} + comment: ${description_comment} #appears on the esphome page in HA + on_boot: #LD1125H Initial Setting, will remember previous values (if set) + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +############################################# +esp32: + #board: nodemcu-32s + board: esp32dev + framework: + #type: arduino + type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + version: recommended #recommended, latest or dev + +############################################# +# i2s bus +# https://esphome.io/components/i2c.html +############################################# +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me + +############################################# +# ESPHome external or custom components to use +# https://esphome.io/components/external_components.html +############################################# +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] #text_sensor that reads lines for a uart. Also, a sensor that reads single values from the uart. + +############################################# +# ESPHome Logging Enable +# https://esphome.io/components/logger.html +############################################# +logger: + level: INFO #INFO Level suggested, or DEBUG for testing + baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 + +############################################# +# Enable the Home Assistant API +# https://esphome.io/components/api.html +############################################# +api: + encryption: + key: ${api_key} + +############################################# +# Enable Over the Air Update Capability +# https://esphome.io/components/ota.html?highlight=ota +############################################# +ota: + safe_mode: true #Safe mode will detect boot loops + password: ${ota_pass} + +############################################# +# Wifi Settings +# https://esphome.io/components/wifi.html +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: #optional static IP address + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode + ssid: $devicename fallback AP + password: !secret fallback_ap_password + ap_timeout: 5min #default is 1min + +############################################# +# Web Portal for display and monitoring +# Turning this off is probably a good idea to save resources. +# https://esphome.io/components/web_server.html +############################################# +web_server: + port: 80 +# username: !secret web_server_username #probably a good idea to secure it +# password: !secret web_server_password + +############################################# +# MQTT Monitoring +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# +mqtt: + broker: !secret mqtt_server + topic_prefix: ${mqtt_topic}/${devicename} + username: !secret mqtt_username + password: !secret mqtt_password + +############################################# +# Bluetooth +# https://esphome.io/components/bluetooth_proxy.html +# https://esphome.io/components/esp32_ble_tracker.html +# Remember that this takes a LOT of processing. On the +# ESP32, enable the IDF framework, and disable the +# Web server component. Changing to the IDF framework +# needs to be via cable not OTA to change the +# partition setup. +############################################# +#bluetooth_proxy: + +#esp32_ble_tracker: + +############################################# +# UART Serial +# hardware on EPS32, but software, and can be glitchy on ESP8266 +# https://esphome.io/components/uart.html?highlight=uart +############################################# +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); + +############################################# +# Global Variables for use in automations etc +# https://esphome.io/guides/automations.html?highlight=globals#global-variables +############################################# +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" + +############################################# +# General esp status LED +# https://esphome.io/components/status_led.html +############################################# +status_led: + pin: + number: GPIO2 #ESP32 Onboard LED + ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins + inverted: false + +############################################# +# Interval Automations +# https://esphome.io/guides/automations.html +############################################# +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + +############################################# +# Number Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +number: + - platform: template + name: ${friendly_name} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${friendly_name} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${friendly_name} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${friendly_name} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${friendly_name} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${friendly_name} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 + +############################################# +# General Sensors +# https://esphome.io/components/sensor/index.html +############################################# +sensor: + - platform: bme280_i2c + temperature: + name: ${friendly_name} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${friendly_name} BME280 Pressure + oversampling: 2x + humidity: + name: ${friendly_name} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} + - platform: uptime + name: ${friendly_name} Uptime + - platform: template + name: ${friendly_name} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s + +############################################# +# Text Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${friendly_name} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${friendly_name} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" + +############################################# +# Binary Sensors +# https://esphome.io/components/binary_sensor/index.html +############################################# +binary_sensor: + - platform: status + name: ${friendly_name} Status + - platform: template + name: ${friendly_name} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${friendly_name} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/esphome/esp-occupancystair.yaml b/esphome/esp-occupancystair.yaml new file mode 100644 index 0000000..1cf341d --- /dev/null +++ b/esphome/esp-occupancystair.yaml @@ -0,0 +1,404 @@ +############################################# +############################################# +# HiLink LD2410 mmWave sensor, with BME280 Temp/Hum/Pres Sensor on an ESP32 +# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/tree/main +# https://github.com/patrick3399/Hi-Link_mmWave_Radar_ESPHome/blob/main/LD1125H/ESP32-LD1125H-Complete.yaml +# +# https://esphome.io/components/sensor/ld2410.html +# https://www.simplysmart.house/blog/presence-detection-ld2410-home-assistant +# +############################################# +############################################# + +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esp-occupancystair" + friendly_name: "Stair Occupancy" + description_comment: "D1 Mini ESP32 with LD2410 mmWave for internal stairwell and environment sensors for under house" + api_key: !secret esp-occupancystair_api_key #unfortunately you can't use substitutions in secrets names + ota_pass: !secret esp-occupancystair_ota_pass #unfortunately you can't use substitutions in secrets names + mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like + update_time: 30s #update time for for temp sensors etc + +############################################# +# ESPHome +# https://esphome.io/components/esphome.html +############################################# +esphome: + name: ${devicename} + comment: ${description_comment} #appears on the esphome page in HA + #on_boot: #Initial Setting, will remember previous values (if set) + #priority: -200 + #then: + + +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +############################################# +esp32: + board: esp32dev + framework: + #type: arduino + type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + version: recommended #recommended, latest or dev + +############################################# +# i2s bus +# https://esphome.io/components/i2c.html +############################################# +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me + +############################################# +# ESPHome Logging Enable +# https://esphome.io/components/logger.html +############################################# +logger: + level: INFO #INFO Level suggested, or DEBUG for testing + baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 + +############################################# +# Enable the Home Assistant API +# https://esphome.io/components/api.html +############################################# +api: + encryption: + key: ${api_key} + +############################################# +# Enable Over the Air Update Capability +# https://esphome.io/components/ota.html?highlight=ota +############################################# +ota: + safe_mode: true #Safe mode will detect boot loops + password: ${ota_pass} + +############################################# +# Wifi Settings +# https://esphome.io/components/wifi.html +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: #optional static IP address + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode + ssid: $devicename fallback AP + password: !secret fallback_ap_password + ap_timeout: 5min #default is 1min + +############################################# +# Web Portal for display and monitoring +# Turning this off is probably a good idea to save resources. +# https://esphome.io/components/web_server.html +############################################# +web_server: + port: 80 +# username: !secret web_server_username #probably a good idea to secure it +# password: !secret web_server_password + +############################################# +# MQTT Monitoring +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# +mqtt: + broker: !secret mqtt_server + topic_prefix: ${mqtt_topic}/${devicename} + username: !secret mqtt_username + password: !secret mqtt_password + +############################################# +# Bluetooth +# https://esphome.io/components/bluetooth_proxy.html +# https://esphome.io/components/esp32_ble_tracker.html +# Remember that this takes a LOT of processing. On the +# ESP32, enable the IDF framework, and disable the +# Web server component. Changing to the IDF framework +# needs to be via cable not OTA to change the +# partition setup. +############################################# +#bluetooth_proxy: + +#esp32_ble_tracker: + +############################################# +# UART Serial +# hardware on EPS32, but software, and can be glitchy on ESP8266 +# https://esphome.io/components/uart.html?highlight=uart +############################################# +uart: + id: ld2410_uart + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 256000 # default for LD2410 is 25600, 8, 0, NONE + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); + +############################################# +# General esp status LED +# https://esphome.io/components/status_led.html +############################################# +status_led: + pin: + number: GPIO2 #ESP32 Onboard LED + ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins + inverted: false + + +############################################# +# LD2410 Sensors +# https://esphome.io/components/sensor/ld2410.html +# https://www.hlktech.net/index.php?id=988 +############################################# +ld2410: + uart_id: ld2410_uart + #uart_id (Optional, ID): Manually specify the ID of the UART Component if you want to use multiple UART buses. + #throttle (Optional, int): Time in milliseconds to control the rate of data updates. Defaults to 1000ms. + #id (Optional, ID): Manually specify the ID for this LD2410 Sensor component if you need multiple components. + +# light (Optional, int): When in engineering mode, indicates the light sensitivity, otherwise unknown. Value between 0 and 255 inclusive. Though it seems that the value 85 is the lowest value at complete darkness. All options from Sensor. +# moving_distance (Optional, int): Distance in cm of detected moving target. All options from Sensor. +# still_distance (Optional, int): Distance in cm of detected still target. All options from Sensor. +# moving_energy (Optional, int): Energy for moving target. Value between 0 and 100 inclusive. All options from Sensor. +# still_energy (Optional, int): Energy for still target. Value between 0 and 100 inclusive. All options from Sensor. +# detection_distance (Optional, int): Distance in cm of target. All options from Sensor. +# gX (Optional): Energies for the Xth gate (X => 0 to 8). + # move_energy (Optional, int): When in engineering mode, the move energy of the gate, otherwise unknown. Value between 0 and 100 inclusive. All options from Sensor. + #still_energy (Optional, int): When in engineering mode, the still energy of the gate, otherwise unknown. Value between 0 and 100 inclusive. All options from Sensor. +#ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components. + +#The ld2410 number values for setting thresholds +# timeout: 5s +# max_move_distance: 2.25m +# max_still_distance: 2.25m +# g0_move_threshold: 40 # 0m / 0' +# g0_still_threshold: 10 # 0m / 0' +# g1_move_threshold: 40 # 0 - 0.75m / 0 - 2.46' +# g1_still_threshold: 10 # 0 - 0.75m / 0 - 2.46' +# g2_move_threshold: 40 # 0.75 - 1.5m / 2.46' - 4.92' +# g2_still_threshold: 10 # 0.75 - 1.5m / 2.46' - 4.92' +# g3_move_threshold: 40 # 1.5 - 2.25m / 4.92' - 7.38' +# g3_still_threshold: 10 # 1.5 - 2.25m / 4.92' - 7.38' +# g4_move_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84' +# g4_still_threshold: 40 # 2.25 - 3m' / 7.38' - 9.84' +# g5_move_threshold: 40 # 3 - 3.75 / 9.84' - 12.30' +# g5_still_threshold: 40 # 3 - 3.75 / 9.84' - 12.30' +# g6_move_threshold: 30 # 3.75 - 4.5m / 12.30' - 14.76' +# g6_still_threshold: 15 # 3.75 - 4.5m / 12.30' - 14.76' +# g7_move_threshold: 30 # 4.5 - 5.25m / 14.76' - 17.22' +# g7_still_threshold: 15 # 4.5 - 5.25m / 14.76' - 17.22' +# g8_move_threshold: 30 # 5.25 - 6m / 17.22' - 19.68' +# g8_still_threshold: 15 # 5.25 - 6m / 17.22' - 19.68' +number: + - platform: ld2410 + timeout: + name: Timeout + light_threshold: + name: Light Threshold + max_move_distance_gate: + name: Max Move Distance Gate + max_still_distance_gate: + name: Max Still Distance Gate + g0: + move_threshold: + name: g0 move threshold + still_threshold: + name: g0 still threshold + g1: + move_threshold: + name: g1 move threshold + still_threshold: + name: g1 still threshold + g2: + move_threshold: + name: g2 move threshold + still_threshold: + name: g2 still threshold + g3: + move_threshold: + name: g3 move threshold + still_threshold: + name: g3 still threshold + g4: + move_threshold: + name: g4 move threshold + still_threshold: + name: g4 still threshold + g5: + move_threshold: + name: g5 move threshold + still_threshold: + name: g5 still threshold + g6: + move_threshold: + name: g6 move threshold + still_threshold: + name: g6 still threshold + g7: + move_threshold: + name: g7 move threshold + still_threshold: + name: g7 still threshold + g8: + move_threshold: + name: g8 move threshold + still_threshold: + name: g8 still threshold + +#The ld2410 select allows you to control your LD2410 Sensor. +#distance_resolution (Optional): Control the gates distance resolution. Can be 0.75m or 0.2m. Defaults to 0.75m. All options from Select. +#baud_rate (Optional): Control the serial port baud rate. Defaults to 256000. Once changed, all sensors will stop working until a fresh install with an updated UART Component configuration. All options from Select. +#light_function (Optional): If set, will affect the OUT pin value, based on light threshold. Can be off, low or above. Defaults to off. All options from Select. +#out_pin_level (Optional): Control OUT pin away value. Can be low or high. Defaults to low. All options from Select. +#ld2410_id (Optional, ID): Manually specify the ID for the LD2410 Sensor component if you are using multiple components. +select: + - platform: ld2410 + distance_resolution: + name: "distance resolution" + baud_rate: + name: "baud rate" + light_function: + name: light function + out_pin_level: + name: out pin level + +############################################# +# General Sensors +# https://esphome.io/components/sensor/index.html +############################################# +sensor: + - platform: bme280_i2c + temperature: + name: ${friendly_name} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${friendly_name} BME280 Pressure + oversampling: 2x + humidity: + name: ${friendly_name} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} + - platform: uptime + name: ${friendly_name} Uptime +#The ld2410 sensor values + - platform: ld2410 + light: + name: Light + moving_distance: + name : Moving Distance + still_distance: + name: Still Distance + moving_energy: + name: Move Energy + still_energy: + name: Still Energy + detection_distance: + name: Detection Distance + g0: + move_energy: + name: g0 move energy + still_energy: + name: g0 still energy + g1: + move_energy: + name: g1 move energy + still_energy: + name: g1 still energy + g2: + move_energy: + name: g2 move energy + still_energy: + name: g2 still energy + g3: + move_energy: + name: g3 move energy + still_energy: + name: g3 still energy + g4: + move_energy: + name: g4 move energy + still_energy: + name: g4 still energy + g5: + move_energy: + name: g5 move energy + still_energy: + name: g5 still energy + g6: + move_energy: + name: g6 move energy + still_energy: + name: g6 still energy + g7: + move_energy: + name: g7 move energy + still_energy: + name: g7 still energy + g8: + move_energy: + name: g8 move energy + still_energy: + name: g8 still energy + +# The ld2410 switch allows you to control your LD2410 Sensor. +switch: + - platform: ld2410 + engineering_mode: + name: "Engineering Mode" + bluetooth: + name: "Control Bluetooth" + +#The ld2410 binary sensors to get presence notification +binary_sensor: + - platform: ld2410 + has_target: + name: Presence + has_moving_target: + name: Moving Target + has_still_target: + name: Still Target + out_pin_presence_status: + name: Out Pin Presence Status + +#The ld2410 button allows resetting +button: + - platform: ld2410 + factory_reset: + name: "Factory reset" + restart: + name: "Restart" + query_params: + name: Query Parameters + +#The ld2410 text sensor allows you to get information about your LD2410 Sensor. +text_sensor: + - platform: ld2410 + version: + name: "Firmware Version" + mac_address: + name: "MAC Address" \ No newline at end of file diff --git a/esphome/esp-netcupfan2.yaml b/esphome/esp-ranchsliderfans.yaml similarity index 87% rename from esphome/esp-netcupfan2.yaml rename to esphome/esp-ranchsliderfans.yaml index 4c14c1a..d943cb4 100644 --- a/esphome/esp-netcupfan2.yaml +++ b/esphome/esp-ranchsliderfans.yaml @@ -2,7 +2,7 @@ # ESPHome ############################################# esphome: - name: esp-netcupfan2 + name: esp-ranchsliderfans ######################################## # Specific board for ESPHome device @@ -20,7 +20,7 @@ logger: ############################################# api: encryption: - key: !secret esp-netcupfan2_api_key + key: !secret esp-ranchsliderfans_api_key ############################################# # Enable Over the Air Update Capability @@ -28,18 +28,19 @@ api: ############################################# ota: safe_mode: true - password: !secret esp-netcupfan2_ota_pass + password: !secret esp-ranchsliderfans_ota_pass ############################################# # Use Wifi ############################################# wifi: + #use_address: esp-netcupfan2.local ssid: !secret wifi_ssid password: !secret wifi_password # Details for fallback hotspot # in case wifi connection fails ap: - ssid: "Netcupfan2 Fallback Hotspot" + ssid: "Ranchsliderfans Fallback Hotspot" password: !secret fallback_ap_password ############################################# @@ -61,7 +62,7 @@ web_server: ############################################# mqtt: broker: !secret mqtt_server - topic_prefix: esphome/esp-netcupfan2 + topic_prefix: esphome/esp-ranchsliderfans username: !secret mqtt_username password: !secret mqtt_password @@ -74,14 +75,14 @@ mqtt: # Relay Output on a GPIO Pin switch: - platform: gpio - name: "Relay_Main" + name: "Ranch Slider Fan Boost" pin: GPIO15 # Allows a fan control point in Home Assistant fan: - platform: speed output: pwm_output - name: "Net Cupboard Fan 2 Speed" + name: "Ranch Slider Fans Speed" speed_count: 500 # PWM Fan Output on the GPIO Pin diff --git a/esphome/esp-weatherstation.yaml b/esphome/esp-weatherstation.yaml new file mode 100644 index 0000000..abfaeb8 --- /dev/null +++ b/esphome/esp-weatherstation.yaml @@ -0,0 +1,855 @@ +############################################# +############################################# +# Opengreen energy weather station board, with ESP8266 D1 Mini +# https://www.opengreenenergy.com/solar-powered-wifi-weather-station-v2-0/ +# zorruno 2024-05-04 V0.0 Untested +# zorruno 2024-05-23 V1.0 Tidied up sensor info and added BMP280 +# zorruno 2024-05-24 V1.1 Tested ok and added some V calibration for mine +# zorruno 2024-05-25 V2 A bunch more sensors added (wind direction not yet sorted) +############################################# +############################################# + +############################################# +# SENSORS INCLUDED +#  +# TESTED WORKING +# status_led: +# uptime: +# wifi_signal: +# battery voltage (adc A0) +# +# ads1115: 4 Channel A->D (0x48 i2c) +# dht: DHT22 Temp/Humidity, Remote (GPIO15) +# bmp280: Temp/pressure on the board (0x76 i2c) +# pulse_meter: Wind Speed (GPIO13) +# +# text_sensor: Beaufort Wind Scale Labelling +# text:sensor: Temp (av) Average of all temps +#  +# TO TEST (HAVE SENSOR or doesn't need one) +# tsl2561: Ambient Light sensor (0x39 i2c) +# ads1115 A1_GND: UV Index +# ads1115 A0_GND: Wind Direction +# pulse_meter: Rainfall (GPIO??) +# battery life: Time from battery starting to drop (retain) +# +# ORDERED BUT DON'T HAVE YET +# ltr390: Ambient Light and UV sensor (0x53 i2c) +# pmsx003: PM Particulate Filter (UART) +# +# NOT USED (code commented) +# bme280_i2c: Temp/humid/press (not used) +# +# POSSIBLY ADD +# Analogue for Solar V? +# Lightning? +# ground movement/earthquake? +# water sensor (rain now) +# +############################################# + +############################################# +# WIND SENSOR +# looks like this one +# https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf +############################################# + +############################################# +# USEFUL LINKS +# Wind Sensing +# https://community.home-assistant.io/t/measuring-wind-speed/395693/20 +# https://community.home-assistant.io/t/measuring-wind-speed/395693/21 +############################################# + +############################################# +# Pulse Meter Issues 202405 +# https://github.com/esphome/issues/issues/4807 +# https://github.com/esphome/issues/issues/3143 +############################################# +external_components: + - source: github://TrentHouliston/esphome@loop_pulse_isr + components: [ pulse_meter ] + +############################################# +# Variable Substitutions +# Give this a useful name & description here +# and change values accordingly +############################################# +substitutions: + devicename: "esp-weatherstation" + friendly_name: "Weather Station" + description_comment: "Opengreen energy board, with BME280 Temp/Hum/Pres Sensor on an ESP8266 D1 Mini" + api_key: !secret esp-weatherstation_api_key #unfortunately you can't use substitutions in secrets names + ota_pass: !secret esp-weatherstation_ota_pass #unfortunately you can't use substitutions in secrets names + wifi_ssid: !secret wifi_ssid + wifi_pass: !secret wifi_password + mqtt_server: 192.168.3.200 + mqtt_topic: "esphome" #main topic for the mqtt server, call it what you like + update_time: 30s #update time for for temp sensors etc + +############################################# +# ESPHome +# https://esphome.io/components/esphome.html +############################################# +esphome: + name: ${devicename} + comment: ${description_comment} #appears on the esphome page in HA + #on_boot: #Initial Setting stuff + #priority: -200 + #then: + +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp32.html OR +# https://esphome.io/components/esp8266.html +############################################# +#esp32: +# board: +# framework: +# type: arduino +# #type: esp-idf #Suggested Use ESP-IDF Framework for ESP32, or unplugging the UART Cable Might Cause ESP32 Hang. +# version: recommended #recommended, latest or dev + +esp8266: + board: d1_mini + +############################################# +# i2c bus +# https://esphome.io/components/i2c.html +# Put the relevant pins here, 4/5 are default for ESP8266 +# and 21/22 for esp32 (although esp32 can have two buses) +############################################# +i2c: + sda: GPIO4 + scl: GPIO5 + scan: True + #frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me for ESP32, default is 50kHz + +############################################# +# ESPHome Logging Enable +# https://esphome.io/components/logger.html +############################################# +logger: + level: DEBUG #INFO Level suggested, or DEBUG for testing + #baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 + +############################################# +# Enable the Home Assistant API +# https://esphome.io/components/api.html +############################################# +api: + encryption: + key: ${api_key} + +############################################# +# Enable Over the Air Update Capability +# https://esphome.io/components/ota.html?highlight=ota +############################################# +ota: + safe_mode: true #Safe mode will detect boot loops + password: ${ota_pass} + +############################################# +# Wifi Settings +# https://esphome.io/components/wifi.html +############################################# +wifi: + ssid: ${wifi_ssid} + password: ${wifi_pass} + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: #optional static IP address + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + ap: #Details for fallback hotspot (captive portal) in case wifi connection fails https://esphome.io/components/wifi.html#access-point-mode + ssid: $devicename fallback AP + password: !secret fallback_ap_password + ap_timeout: 5min #default is 1min + +############################################# +# Web Portal for display and monitoring +# Turning this off if you don't really need it +# is probably a good idea to save resources. +# Also, don't use it with other big ESP32 components +# such as Bluetooth proxy (it will run out of flash +# and not compile, or it will crash occasionally) +# https://esphome.io/components/web_server.html +############################################# +#web_server: +# port: 80 +# version: 1 #V1 occasionally works better, V2 The nicer page +# username: !secret web_server_username #probably a good idea to secure it +# password: !secret web_server_password + +############################################# +# MQTT Monitoring +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# +mqtt: + broker: ${mqtt_server} + topic_prefix: ${mqtt_topic}/${devicename} + #username: !secret mqtt_username + #password: !secret mqtt_password + + #A way to prevent deep sleep using MQTT command + #on_message: + #- topic: ${mqtt_topic}/${devicename}/deepsleepoff + #payload: 'ON' + #then: + #- deep_sleep.prevent: deep_sleep_1 + #- topic: ${mqtt_topic}/${devicename}/deepsleepon + #payload: 'ON' + #then: + #- deep_sleep.enter: deep_sleep_1 + +######################################## +# Deep Sleep +# https://esphome.io/components/deep_sleep.html +######################################## +#deep_sleep: +# run_duration: 20s +# sleep_duration: 10min +# id: deep_sleep_1 + +############################################# +# General espHome status LED +# Not needed, but can be useful to see issues +# https://esphome.io/components/status_led.html +############################################# +status_led: + pin: + number: GPIO2 #Wemos ESP32 and ESP8266 Onboard LEDs use GPIO2 + inverted: false + #ignore_strapping_warning: True #https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins + + ################################ + # 4 Input A->D sensor + # Analog sensor for voltage reading + # https://esphome.io/components/sensor/ads1115.html + ################################ +ads1115: + - address: 0x48 #On the ADS1115 pull address pin to VCC for 0x49. Default is 0x48 + +############################################# +# Text Sensors +# https://esphome.io/components/text_sensor/index.html +############################################# +text_sensor: + - platform: template + name: ${friendly_name} Beaufort Wind Scale + icon: "mdi:tailwind" + id: wind_scale + update_interval: never + - platform: template + name: ${friendly_name} Wind Direction + icon: "mdi:tailwind" + id: wind_dir + update_interval: never + +############################################# +# General Sensors +# https://esphome.io/components/sensor/index.html +############################################# +sensor: + + ################################ + # BMP280 temp/pressure + # https://esphome.io/components/sensor/bmp280.html + ################################ + - platform: bmp280 + address: 0x76 + iir_filter: 16X + update_interval: ${update_time} + temperature: + name: ${friendly_name} BMP280 Temperature + id: bmp280_temp + unit_of_measurement: "°C" + oversampling: 16x + #retain: true #MQTT retain useful if sleeping + pressure: + name: ${friendly_name} BMP280 Pressure + unit_of_measurement: "hPa" + oversampling: 16X + #retain: true #MQTT retain useful if sleeping + + + ################################ + # BME280 temp/humidity/pressure + # https://esphome.io/cookbook/bme280_environment.html + ################################ + #- platform: bme280_i2c + # address: 0x76 + # update_interval: ${update_time} + # temperature: + # name: ${friendly_name} BME280 Temp + # accuracy_decimals: 1 + # oversampling: 2x + # unit_of_measurement: "°C" + # #retain: true #MQTT retain useful if sleeping + # pressure: + # name: ${friendly_name} BME280 Pressure + # oversampling: 2x + # unit_of_measurement: "hPa" + # #retain: true #MQTT retain useful if sleeping + # humidity: + # name: ${friendly_name} BME280 Humidity + # accuracy_decimals: 1 + # oversampling: 2x + # unit_of_measurement: "%" + # #retain: true #MQTT retain useful if sleeping + + + + ################################ + # DHT temp/humidity + # https://esphome.io/components/sensor/dht.html + ################################ + - platform: dht + pin: GPIO15 #D8 on the D1 Mini ESP8266 + update_interval: ${update_time} + temperature: + name: ${friendly_name} DHT22 Temperature + id: dht_temp + unit_of_measurement: "°C" + #retain: true #retain useful if sleeping + humidity: + name: ${friendly_name} DHT22 Humidity + unit_of_measurement: "%" + #retain: true #retain useful if sleeping + + ################################ + # TSL2561 ambient light sensor + # https://esphome.io/components/sensor/tsl2561.html + ################################ + #- platform: tsl2561 + # name: ${friendly_name} Ambient Light + # address: 0x39 + # update_interval: 60s + + ################################ + # LTR390 Ambient Light and UV Sensor + # https://esphome.io/components/sensor/ltr390.html + ################################ + #- platform: ltr390 + # address: 0x35 + # uv_index: + # name: ${friendly_name} 390 UV Index + # uv: + # name: ${friendly_name} 390 UV Sensor Counts + # light: + # name: ${friendly_name} 390 Light + # ambient_light: + # name: ${friendly_name} 390 UV Sensor Counts + # update_interval: 60s + + ################################ + # PMSX003 Particulate sensor + # NEEDS UART SET FIRST + # https://esphome.io/components/sensor/pmsx003.html + ################################ + #- platform: pmsx003 + # type: PMSX003 + # pm_1_0: + # name: ${friendly_name} Particulate Matter <1.0µm + # pm_2_5: + # name: ${friendly_name} <2.5µm + # pm_10_0: + # name: ${friendly_name} <10.0µm Concentration + + ################################ + # Device uptime info + # https://esphome.io/components/sensor/uptime.html + ################################ + - platform: uptime + name: ${friendly_name} Uptime + +################################ +# Quality of Wifi in dBm +# https://esphome.io/components/sensor/wifi_signal.html +################################ + - platform: wifi_signal + name: ${friendly_name} WiFi Signal + update_interval: ${update_time} + #retain: true #retain useful if sleeping + + ################################ + # Analog sensor for voltage reading + # (A0 on esp8266) + # https://esphome.io/components/sensor/adc.html + ################################ + - platform: adc + name: ${friendly_name} Battery Voltage + id: battery_voltage + pin: A0 + unit_of_measurement: "V" + accuracy_decimals: 5 + update_interval: ${update_time} + #retain: true #retain useful if sleeping + filters: + - multiply: 5.223 # tested with multimeter + - calibrate_linear: + - 3.89 -> 3.90 + - 3.85 -> 3.92 + - 4.09 -> 4.14 + + - platform: template + name: ${friendly_name} Av Battery Voltage over 5 mins + id: battery_voltage_5minav + unit_of_measurement: "V" + accuracy_decimals: 5 + update_interval: 30s #updates every 30s + lambda: > + return id(battery_voltage).state; //grabs values from the battery_voltage + filters: + - sliding_window_moving_average: + window_size: 20 #20x 30s = 10 mins + send_every: 1 + send_first_at: 1 + + - platform: duty_time + id: battery_discharge_time + name: ${friendly_name} Time battery is discharging + unit_of_measurement: "Mins" + retain: true #retain this as when device dies, we still want the value + # Support logical sources (optional): 'binary_sensor' + accuracy_decimals: 0 + filters: + - multiply: 0.01666666 + - round: 0 + lambda: > + return { id(battery_voltage).state <= id(battery_voltage_5minav).state }; + + + + ################################ + # Wind Direction, Analogue on ADS115 + # Analog sensor for voltage reading + # https://esphome.io/components/sensor/ads1115.html + ################################ + # Using a analog wind direction sensor that has an output + # of 0 - 5 V for 360° representing the position of the arrow + # from the north pole. This is 5V divided by 8 resistor + # values giving the output voltage value for each azimuth. + # We could also report a compass direction. + ################################ + - platform: ads1115 + multiplexer: 'A0_GND' + gain: 6.144 + name: ${friendly_name} Wind Direction + id: wind_direction + update_interval: 5s +# filters: +# lambda: |- +# if( (x * (360.0/5.0)) >= 10.0 && (x * (360.0/5.0)) <= 70.0 ) { return x = 45 }; +# else if( (x * (360.0/5.0)) > 70.0 && (x * (360.0/5.0)) <= 120.0 ) { return x = 90 }; +# else if( (x * (360.0/5.0)) > 120.0 && (x * (360.0/5.0)) <= 170.0 ) { return x = 135 }; +# else if( (x * (360.0/5.0)) > 170.0 && (x * (360.0/5.0)) <= 215.0 ) { return x = 180 }; +# else if( (x * (360.0/5.0)) > 215.0 && (x * (360.0/5.0)) <= 262.0 ) { return x = 225 }; +# else if( (x * (360.0/5.0)) > 262.0 && (x * (360.0/5.0)) <= 330.0 ) { return x = 270 }; +# else if( (x * (360.0/5.0)) > 330.0 && (x * (360.0/5.0)) <= 355.0 ) { return x = 315 }; +# else if(((x * (360.0/5.0)) > 355.0 && (x * (360.0/5.0)) <= 360.0) || ((x * (360.0/5.0)) >= 0.0 && (x * (360.0/5.0)) <= 10.0)) { return x = 0 }; + +# - platform: template +# name: ${friendly_name} Winddirection Degrees +# id: wind_direction_voltage +# lambda: return id(wind_direction_voltage).state; +# unit_of_measurement: "degrees" +# update_interval: 5s +# filters: +# - throttle_average: 5s +# on_value: +# lambda: |- +# if (id(wind_direction_voltage).state * (360.0/5.0) >= 10.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 70.0) { +# id(wind_dir).publish_state("45"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 70.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 120.0) { +# id(wind_dir).publish_state("90"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 120.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 170.0) { +# id(wind_dir).publish_state("135"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 170.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 215.0) { +# id(wind_dir).publish_state("180"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 215.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 262.0) { +# id(wind_dir).publish_state("225"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 262.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 330.0) { +# id(wind_dir).publish_state("270"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 330.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 355.0) { +# id(wind_dir).publish_state("315"); +# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 355.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 360.0) { +# id(wind_dir).publish_state("0"); +# } else { +# id(wind_dir).publish_state("0"); +# } + +# - platform: ads1115 +# multiplexer: "A1_GND" +# gain: 6.144 +# name: ${friendly_name} UV Index +# update_interval: 10s +# unit_of_measurement: "mW/cm2" +# accuracy_decimals: 1 + + + +# - platform: pulse_meter +# pin: + # number: GPIO13 #This is Pin D7 on the D1 Mini ESP8266 + # mode: +# input: true +# pullup: true +# name: ${friendly_name} Wind speed +# id: wind_meter +# unit_of_measurement: m/s +# accuracy_decimals: 1 +# timeout: 5s +# internal_filter_mode: EDGE +# internal_filter: 10ms + + # A wind speed of 2.4km/h (1.492mph) causes the switch to close once per second. + # that is 0.667m/s. + # Switch closes twice per revolution + + # rotations_per_sec = pulses / 2 / 60 + # circ_m = 0.09 * 2 * 3.14 = 0.5652 + # mps = 1.18 * circ_m * rotations_per_sec + # mps = 1.18 * (0.5652 / 2 / 60) = 0.0055578 +# +# filters: +# # - multiply: 0.0055578 #use for m/s +# # - multiply: 2.237 #m/s to mph +# # - multiply: 0.0124327986 #m/s * mph conversion +# # - multiply: ? #m/s to kph +# - multiply: 0.0055578 +# - sliding_window_moving_average: # Helps prevent too many datapoints +# window_size: 10 +# send_every: 10 + + ################################ + # Pulse Meter for measuring wind speed + # Analog sensor for voltage reading + # https://esphome.io/components/sensor/pulse_meter.html + # + # This Anenometer https://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf + # + # The cup-type anemometer measures wind speed by closing a contact + # as a magnet moves past a reed switch. A wind speed of 1.492mph (2.4km/h) (0.667m/s) + # causes the switch to close once per second. The reed switch closes twice per revolution. + # 1rps = 60rpm = 2.4kmh + # 1pulse/min = 2.4kmh/60 = 0.04kmh + # Pulse meter component measures the time between rising edges on a pin, + # for each pulse it outputs the frequency in pulses/min. + ################################ + - platform: pulse_meter # https://community.home-assistant.io/t/measuring-wind-speed/395693 + id: wind_meter + pin: + number: GPIO13 + mode: + input: true + pullup: true + #internal: true # If true, don't send to HA/MQTT etc + internal_filter_mode: EDGE + internal_filter: 10ms + name: ${friendly_name} Wind speed + icon: "mdi:weather-windy" + unit_of_measurement: "km/h" + accuracy_decimals: 1 + timeout: 5s + filters: + - timeout: + timeout: "5s" #after 5 seconds, if no pulses received.... + value: 0 #make the value = 0 + - multiply: 0.04 #kmh + - sliding_window_moving_average: # Moving average to prevent too many data points + window_size: 10 + send_every: 10 + - clamp: + min_value: 0 + max_value: 250 #if anything over that, we have debounce issues or are going to die + ignore_out_of_range: true + +# on_value: +# lambda: |- +# if(x > id(g_WindGust_10min)) { +# id(g_WindGust_10min) = x; +# id(id_wind_gust_10min).publish_state(id(g_WindGust_10min)); +# }; +# //id(g_wind_run) += (x>0) ? 0.000666982 : 0; +# if(x > id(g_WindGust_10s)) { +# id(g_WindGust_10s) = x; +# id(id_wind_gust_10s).publish_state(id(g_WindGust_10s)); +# }; +# if(x > id(g_WindGust_60s)) { +# id(g_WindGust_60s) = x; +# id(id_wind_gust_60s).publish_state(id(g_WindGust_60s)); +# }; + + +# if(id(g_WindSpeedMin_Reset)){ +# id(g_WindSpeedMin_10s) = x; +# id(g_WindSpeedMin_Reset) = false; +# } else { +# if(x < id(g_WindSpeedMin_10s)) {id(g_WindSpeedMin_10s) = x;}; +# } +# total: +# name: "Roof Wind Run daily" +# id: id_wind_run_daily +# internal: false +# unit_of_measurement: "km" +# accuracy_decimals: 3 +# filters: +# - multiply: 0.000666982 +# - throttle: 30s + + + - platform: template + name: ${friendly_name} Windspeed Gust (Max last 10m) + unit_of_measurement: "km/h" + update_interval: 2s #updates every 2s + lambda: > + return id(wind_meter).state; //grabs values from the wind_sensor + filters: + - filter_out: nan #in case there is no value + - max: + window_size: 300 #10 Min window as 2s update x 300 = 10min + send_every: 1 #updates on the 1st 2s check + send_first_at: 1 #on restart, send after first 10s + + +# https://www.reddit.com/r/Esphome/comments/kndues/take_max_value_over_time/ +# - platform: template +# name: ${friendly_name} Windspeed last 10min max +# #id: ${node_name}_pm_1_0_rolling_30_minute_average +# unit_of_measurement: "km/h" +# update_interval: 60s +# lambda: |- +# const size_t window_size_ = 10; +# const size_t send_every_ = 10; +# static size_t send_at_ = 0; + +# static std::deque queue_; +# if (!isnan(x)) { +# if (queue_.size() >= window_size_) { +# queue_.pop_front(); +# } +# queue_.push_back(x); +# } + +# if (++send_at_ >= send_every_) { +# send_at_ = 0; +# if (!queue_.empty()) { +# std::deque::iterator it = std::max_element(queue_.begin(), queue_.end()); +# return *it; +# } +# return 0.0f; +# } +# return {}; + + +# - platform: template +# name: "Roof Wind Run daily" +# icon: "mdi:weather-windy" +# unit_of_measurement: "km" +# accuracy_decimals: 3 +# update_interval: 30s +# internal: true +# lambda: |- +# return id(g_wind_run_count)*0.000666982; +# id: id_wind_run_daily_g + +# - platform: template +# name: "Roof Wind gust 10s" +# unit_of_measurement: 'km/h' +# update_interval: 10s +# id: id_wind_gust_10s +# lambda: return id(g_WindGust_10s); +# +# - platform: template +# name: "Roof Wind gust 60s" +# unit_of_measurement: 'km/h' +# state_class: "measurement" +# update_interval: 60s +# id: id_wind_gust_60s +# lambda: return id(g_WindGust_60s); + +# - platform: template +# name: "Roof Wind gust 10min" +# unit_of_measurement: 'km/h' +# state_class: "measurement" +# update_interval: 10min +# id: id_wind_gust_10min +# lambda: return id(g_WindGust_10min); + +# - platform: template +# name: "Roof Wind speed avg 1s" +# unit_of_measurement: 'km/h' +# update_interval: 333ms +# lambda: |- +# return id(id_wind_speed).state; +# filters: +# throttle_average: 1s +# id: id_wind_speed_avg_1s +# +# - platform: template +# name: "Roof Wind speed avg 10s" +# unit_of_measurement: 'km/h' +# update_interval: 333ms +# lambda: |- +# return id(id_wind_speed).state; +# filters: +# throttle_average: 10s +# id: id_wind_speed_avg_10s +# +# - platform: template +# name: "Roof Wind Speed Min 10s" +# unit_of_measurement: 'km/h' +# id: id_wind_speed_min_10s +# +# - platform: template +# name: "Roof Wind speed avg 1min" +# unit_of_measurement: 'km/h' +# state_class: "measurement" +# update_interval: '1s' +# lambda: |- +# return id(id_wind_speed).state; +# filters: +# - throttle_average: 1min +# id: id_wind_speed_avg_1min +# +# - platform: template +# name: "Roof Wind speed avg 10min" +# unit_of_measurement: 'km/h' +# state_class: "measurement" +# update_interval: 1s +# lambda: |- +# return id(id_wind_speed).state; +# filters: +# - throttle_average: 10min +# id: id_wind_speed_avg_10min + + + + ################################ + # Averaging for the various temp sensors on board + ################################ + - platform: template + name: ${friendly_name} Temp (av) + icon: "mdi:thermometer" + unit_of_measurement: "°C" + lambda: |- + return ( + id(bmp280_temp).state + + + id(dht_temp).state + ) / 2; + + ################################ + # Template for Beaufort for measuring wind speed + # https://windy.app/blog/wind-speed-beaufort-scale.html + ################################ +# - platform: template +# name: ${friendly_name} Windspeed Scale +# icon: "mdi:weather-windy" +# id: wind_meter_scale +# lambda: return id(wind_meter).state; +# unit_of_measurement: "m/s" +# update_interval: 5s +# filters: +# - throttle_average: 5s +# on_value: +# lambda: |- +# if (id(wind_meter_scale).state < 0.1) { +# id(wind_scale).publish_state("Calm"); +# } else if (id(wind_meter_scale).state > 0 && id(wind_meter_scale).state < 2) { +# id(wind_scale).publish_state("Light Air"); +# } else if (id(wind_meter_scale).state >= 2 && id(wind_meter_scale).state < 3) { +# id(wind_scale).publish_state("Light Breeze"); +# } else if (id(wind_meter_scale).state >= 3 && id(wind_meter_scale).state < 5) { +# id(wind_scale).publish_state("Gentle Breeze"); +# } else if (id(wind_meter_scale).state >= 5 && id(wind_meter_scale).state < 8) { +# id(wind_scale).publish_state("Moderate Breeze"); +# } else if (id(wind_meter_scale).state >= 8 && id(wind_meter_scale).state < 11) { +# id(wind_scale).publish_state("Fresh Breeze"); +# } else if (id(wind_meter_scale).state >= 11 && id(wind_meter_scale).state < 14) { +# id(wind_scale).publish_state("Strong Breeze"); +# } else if (id(wind_meter_scale).state >= 14 && id(wind_meter_scale).state < 17) { +# id(wind_scale).publish_state("Near Gale"); +# } else if (id(wind_meter_scale).state >= 17 && id(wind_meter_scale).state < 21) { +# id(wind_scale).publish_state("Gale"); +# } else if (id(wind_meter_scale).state >= 21 && id(wind_meter_scale).state < 24) { +# id(wind_scale).publish_state("Severe Gale"); +# } else if (id(wind_meter_scale).state >= 24 && id(wind_meter_scale).state < 28) { +# id(wind_scale).publish_state("Storm"); +# } else if (id(wind_meter_scale).state >= 28 && id(wind_meter_scale).state < 33) { +# id(wind_scale).publish_state("Violent Storm"); +# } else if (id(wind_meter_scale).state >= 33) { +# id(wind_scale).publish_state("Hurricane Force"); +# } else { +# id(wind_scale).publish_state(""); +# } + +#switch: +# - platform: template +# optimistic: true +# name: switch +# #internal: True +# id: g_WindSpeedMin_Reset + +#interval: +# - interval: 10s +# then: +# - lambda: |- +# id(g_WindSpeedMin_Reset).state == true; +# //id(id_wind_gust_10s).publish_state(id(g_WindGust_10s)); +# id(id_wind_speed_min_10s).publish_state(id(g_WindSpeedMin_10s)); +# //id(id_wind_gust_60s).publish_state(id(g_WindGust_60s)); +# //id(id_wind_gust_10min).publish_state(id(g_WindGust_10min)); +# id(g_WindGust_10s) = 0; +# // id(g_WindSpeedMin_10s) = 9999.9; +# id(g_WindSpeedMin_Reset) = true; +# - interval: 60s +# then: +# - lambda: |- +# id(g_WindGust_60s) = 0; +# //maintain rain +# //if (++id(g_minute) > 59) id(g_minute) = 0; +# //id(gt_rain_hour)[id(g_minute)] = 0; +# - interval: 10min +# then: +# - lambda: |- +# id(g_WindGust_10min) = 0; + + +#globals: +# global variables for wind/rain sensors +# - id: g_WindGust_10min +# type: float +# restore_value: no +# initial_value: '0.0' +# - id: g_wind_run_count +# type: int +# restore_value: no +# initial_value: '0' +# - id: g_rain_count +# type: int +# restore_value: no +# initial_value: '0' +# - id: gt_rain_hour +# type: byte[60] +# restore_value: no +# - id: g_minute +# type: byte +# restore_value: no +# initial_value: '0' +# - id: g_WindGust_10s +# type: float +# restore_value: no +# initial_value: '0.0' +# - id: g_WindSpeedMin_10s +# type: float +# restore_value: no +# initial_value: '9999.9' +# - id: g_WindGust_60s +# type: float +# restore_value: no +# initial_value: '0.0' diff --git a/esphome/esphome-web-7776ec copy.yaml.old b/esphome/esphome-web-7776ec copy.yaml.old new file mode 100644 index 0000000..0b813a3 --- /dev/null +++ b/esphome/esphome-web-7776ec copy.yaml.old @@ -0,0 +1,381 @@ +# https://digiblur.com/2023/05/24/esphome-mmwave-presence-how-to-guide/ + +substitutions: + name: "esphome-web-7776ec" + friendly_name: "esp-mmwave-office" + upper_devicename: "esp-mmwave-office" + update_time: 30s + +esphome: + name: ${name} + friendly_name: ${friendly_name} + name_add_mac_suffix: false + #project: + #name: esphome.web + #version: '1.0' + on_boot: #LD1125H Initial Setting + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + + + + +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + + +############################################# +# ESPHome Logging Enable +############################################# +# NOTE: Baudrate set to 0 as we are using the UART with PZEM +logger: + level: INFO #You Can Use "INFO" Level + baud_rate: 0 + +############################################# +# Enable the Home Assistant API +############################################# +api: + #encryption: + # key: !secret esp-mainovenmonitor_api_key + +############################################# +# Enable Over the Air Update Capability +# Safe mode will detect boot loops +############################################# +ota: + # safe_mode: true + # password: !secret esp-mainovenmonitor_ota_pass + +############################################# +# Use Wifi +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + #power_save_mode: LIGHT + # Details for fallback hotspot (captive portal) + # in case wifi connection fails + ap: + ssid: "MMwave Office Fallback Hotspot" + password: !secret fallback_ap_password +# manual_ip: +# static_ip: 192.168.x.x +# gateway: 192.168.X.x +# subnet: 255.255.255.0 + +############################################# +# MQTT Monitoring +############################################# +mqtt: + broker: !secret mqtt_server + topic_prefix: esphome/esp-mmwave-office + username: !secret mqtt_username + password: !secret mqtt_password + +# Allow provisioning Wi-Fi via serial +#improv_serial: + +############################################# +# Fallback captive portal +############################################# +# In combination with the `ap` this allows the user +# to provision wifi credentials to the device via WiFi AP. +#captive_portal: + +#dashboard_import: +# package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main +# import_full_config: true + +# Sets up Bluetooth LE (Only on ESP32) to allow the user +# to provision wifi credentials to the device. +##esp32_improv: +## authorizer: none + +############################################# +# Web Portal for display and monitoring +############################################# +#web_server: +# port: 80 +# auth: +# username: !secret web_server_username +# password: !secret web_server_password + + +#esp32: +# board: esp32dev +# framework: +# type: arduino +esp32: + board: esp32dev + framework: + type: esp-idf #Suggest Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] + + +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" +status_led: + pin: + number: GPIO2 #ESP32 OnBroad LED + inverted: false +#web_server: #Avoid Using Web Server To Prevent Hang +# port: 80 +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } +number: + - platform: template + name: ${upper_devicename} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${upper_devicename} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${upper_devicename} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${upper_devicename} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 +sensor: + - platform: bme280_i2c + temperature: + name: ${upper_devicename} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${upper_devicename} BME280 Pressure + oversampling: 2x + humidity: + name: ${upper_devicename} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} +# - platform: aht10 +# temperature: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Temp +# humidity: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Humidity +# update_interval: ${update_time} +# - platform: wifi_signal +# name: ${upper_devicename} WiFi Signal +# update_interval: 60s + - platform: uptime + name: ${upper_devicename} Uptime + - platform: template + name: ${upper_devicename} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${upper_devicename} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${upper_devicename} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" +binary_sensor: + - platform: status + name: ${upper_devicename} Status + - platform: template + name: ${upper_devicename} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${upper_devicename} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/esphome/trash/esp-mmwave-office-7776ec.yaml b/esphome/trash/esp-mmwave-office-7776ec.yaml new file mode 100644 index 0000000..79d55a4 --- /dev/null +++ b/esphome/trash/esp-mmwave-office-7776ec.yaml @@ -0,0 +1,370 @@ +# https://digiblur.com/2023/05/24/esphome-mmwave-presence-how-to-guide/ + +substitutions: + name: esp-mmwave-office-7776ec + friendly_name: esp-mmwave-office + update_time: 30s + +esphome: + name: ${name} + friendly_name: ${friendly_name} + name_add_mac_suffix: false + #project: + #name: esphome.web + #version: '1.0' + on_boot: #LD1125H Initial Setting + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + + + +############################################# +# ESPHome Logging Enable +############################################# +# NOTE: Baudrate set to 0 as we are using the UART with PZEM +logger: + level: INFO #You Can Use "INFO" Level + baud_rate: 0 + +############################################# +# Enable the Home Assistant API +############################################# +api: + #encryption: + # key: !secret esp-mainovenmonitor_api_key + +############################################# +# Enable Over the Air Update Capability +# Safe mode will detect boot loops +############################################# +ota: + # safe_mode: true + # password: !secret esp-mainovenmonitor_ota_pass + +############################################# +# Use Wifi +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + power_save_mode: LIGHT + # Details for fallback hotspot (captive portal) + # in case wifi connection fails + ap: + ssid: "MMwave Office Fallback Hotspot" + password: !secret fallback_ap_password +# manual_ip: +# static_ip: 192.168.x.x +# gateway: 192.168.X.x +# subnet: 255.255.255.0 + + +# Allow provisioning Wi-Fi via serial +#improv_serial: + +############################################# +# Fallback captive portal +############################################# +# In combination with the `ap` this allows the user +# to provision wifi credentials to the device via WiFi AP. +captive_portal: + +#dashboard_import: +# package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main +# import_full_config: true + +# Sets up Bluetooth LE (Only on ESP32) to allow the user +# to provision wifi credentials to the device. +##esp32_improv: +## authorizer: none + +############################################# +# Web Portal for display and monitoring +############################################# +#web_server: +# port: 80 +# auth: +# username: !secret web_server_username +# password: !secret web_server_password + + +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + +#esp32: +# board: esp32dev +# framework: +# type: arduino +esp32: + board: nodemcu-32s + framework: + type: esp-idf #Suggest Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] + + +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" +status_led: + pin: + number: GPIO2 #ESP32 OnBroad LED + inverted: false +#web_server: #Avoid Using Web Server To Prevent Hang +# port: 80 +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } +number: + - platform: template + name: ${upper_devicename} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${upper_devicename} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${upper_devicename} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${upper_devicename} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 +sensor: + - platform: bme280_i2c + temperature: + name: ${upper_devicename} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${upper_devicename} BME280 Pressure + oversampling: 2x + humidity: + name: ${upper_devicename} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} +# - platform: aht10 +# temperature: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Temp +# humidity: +# accuracy_decimals: 2 +# name: ${upper_devicename} AHT21 Humidity +# update_interval: ${update_time} +# - platform: wifi_signal +# name: ${upper_devicename} WiFi Signal +# update_interval: 60s + - platform: uptime + name: ${upper_devicename} Uptime + - platform: template + name: ${upper_devicename} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${upper_devicename} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${upper_devicename} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" +binary_sensor: + - platform: status + name: ${upper_devicename} Status + - platform: template + name: ${upper_devicename} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${upper_devicename} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/esphome/trash/esp-mmwave-office.yaml b/esphome/trash/esp-mmwave-office.yaml new file mode 100644 index 0000000..76d8550 --- /dev/null +++ b/esphome/trash/esp-mmwave-office.yaml @@ -0,0 +1,31 @@ +esphome: + name: esp-mmwave-office + friendly_name: esp-mmwave-office + +esp32: + board: esp32dev + framework: + type: arduino + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "KbgRoOmslFkhfRnWgr3RKK6P3Ed3dhHJ+l9FVYZX8lo=" + +ota: + password: "b3a0a1de8ea89ebf360fbeac40af7a0a" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Esp-Mmwave-Office" + password: "EsNR8kqAOUu8" + +captive_portal: + \ No newline at end of file diff --git a/esphome/trash/esp-mmwaveoffice-7776ec.yaml b/esphome/trash/esp-mmwaveoffice-7776ec.yaml new file mode 100644 index 0000000..0550087 --- /dev/null +++ b/esphome/trash/esp-mmwaveoffice-7776ec.yaml @@ -0,0 +1,401 @@ +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esp-mmwaveoffice-7776ec" + friendly_name: "Office Occupancy" + mqtt_topic: "esphome" + update_time: 30s #for temp sensors etc + +############################################# +# ESPHome +# https://esphome.io/components/esphome.html +############################################# +esphome: + name: ${devicename} + comment: D1 Mini ESP32 with mmWave and environment sensors for main office #appears on the esphome page in HA + on_boot: #LD1125H Initial Setting + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +############################################# +esp32: + board: nodemcu-32s + framework: + type: arduino + #type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + version: recommended #recommended, latest or dev + +############################################# +# i2s bus +# https://esphome.io/components/i2c.html +############################################# +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me + +############################################# +# ESPHome external or custom components to use +# https://esphome.io/components/external_components.html +############################################# +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] #text_sensor that reads lines for a uart. Also, a sensor that reads single values from the uart. + +############################################# +# ESPHome Logging Enable +# https://esphome.io/components/logger.html +############################################# +logger: + level: INFO #INFO Level suggested, or DEBUG for testing + baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 + +############################################# +# Enable the Home Assistant API +# https://esphome.io/components/api.html +############################################# +api: + encryption: + key: !secret esp-mmwaveoffice_api_key + +############################################# +# Enable Over the Air Update Capability +# Safe mode will detect boot loops +# https://esphome.io/components/ota.html?highlight=ota +############################################# +ota: + safe_mode: true + password: !secret esp-mmwaveoffice_ota_pass + +############################################# +# Wifi Settings +# https://esphome.io/components/wifi.html +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + #ap: #Details for fallback hotspot (captive portal) in case wifi connection fails + #ssid: "? Fallback Hotspot" + #password: !secret fallback_ap_password + +############################################# +# Web Portal for display and monitoring +# Turning this off is probably a good idea to save resources. +# https://esphome.io/components/web_server.html +############################################# +web_server: + port: 80 +# username: !secret web_server_username +# password: !secret web_server_password + +############################################# +# MQTT Monitoring +# https://esphome.io/components/mqtt.html?highlight=mqtt +# MUST also have api enabled if you enable MQTT +############################################# +mqtt: + broker: !secret mqtt_server + topic_prefix: ${mqtt_topic}/${devicename} + username: !secret mqtt_username + password: !secret mqtt_password + +############################################# +# UART Serial +# hardware on EPS32, but software, and can be glitchy on ESP8266 +# https://esphome.io/components/uart.html?highlight=uart +############################################# +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); + +############################################# +# Global Variables for use in automations etc +# https://esphome.io/guides/automations.html?highlight=globals#global-variables +############################################# +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" + +############################################# +# General esp status LED +# https://esphome.io/components/status_led.html +############################################# +status_led: + pin: + number: GPIO2 #ESP32 Onboard LED + inverted: false + +############################################# +# Interval Automations +# https://esphome.io/guides/automations.html +############################################# +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + +############################################# +# Number Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +number: + - platform: template + name: ${friendly_name} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${friendly_name} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${friendly_name} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${friendly_name} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${friendly_name} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${friendly_name} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 + +############################################# +# General Sensors +# https://esphome.io/components/sensor/index.html +############################################# +sensor: + - platform: bme280_i2c + temperature: + name: ${friendly_name} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${friendly_name} BME280 Pressure + oversampling: 2x + humidity: + name: ${friendly_name} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} + - platform: uptime + name: ${friendly_name} Uptime + - platform: template + name: ${friendly_name} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s + +############################################# +# Text Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${friendly_name} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${friendly_name} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" + +############################################# +# Binary Sensors +# https://esphome.io/components/binary_sensor/index.html +############################################# +binary_sensor: + - platform: status + name: ${friendly_name} Status + - platform: template + name: ${friendly_name} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${friendly_name} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/esphome/trash/esphome-web-7776ec.yaml b/esphome/trash/esphome-web-7776ec.yaml new file mode 100644 index 0000000..b6e7c34 --- /dev/null +++ b/esphome/trash/esphome-web-7776ec.yaml @@ -0,0 +1,393 @@ +############################################# +# Variable Substitutions +############################################# +substitutions: + devicename: "esphome-web-7776ec" + friendly_name: "esp-web-7776ec" + upper_devicename: "esp-web-7776ec" + mqtt_topic: "esphome" + update_time: 30s #for temp sensors etc + +############################################# +# ESPHome +# https://esphome.io/components/esphome.html#esphome-core-configuration +############################################# +esphome: + name: ${devicename} + comment: D1 Mini ESP32 with mmWave and environment sensors for main office #appears on the esphome page in HA + on_boot: #LD1125H Initial Setting + priority: -200 + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",id(LD1125H_mth1).state) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",id(LD1125H_mth2).state) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",id(LD1125H_mth3).state) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",id(LD1125H_rmax).state) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + +############################################# +# ESP Platform and Framework +# https://esphome.io/components/esp32.html +############################################# +esp32: + board: nodemcu-32s + framework: + type: arduino + #type: esp-idf #Suggested Use ESP-IDF Framework, or Plug Out the UART Cable Might Cause ESP32 Hang. + version: recommended #recommended, latest or dev + +############################################# +# i2s bus +# https://esphome.io/components/i2c.html +############################################# +i2c: + sda: GPIO19 + scl: GPIO21 + scan: True + frequency: 100kHz #10, 50, 100, 200, 800 are possible settings, 100kHz was reliable for me + + +############################################# +# ESPHome external or custom components to use +############################################# +external_components: + - source: + type: git + url: https://github.com/ssieb/custom_components #Thanks for @ssieb components. + components: [ serial ] #text_sensor that reads lines for a uart. Also, a sensor that reads single values from the uart. + +############################################# +# ESPHome Logging Enable +############################################# +logger: + level: INFO #INFO Level suggested, or DEBUG for testing + baud_rate: 0 #set to 0 for no logging via UART, needed if you are using it for other serial things (eg PZEM) + #esp8266_store_log_strings_in_flash: false + #tx_buffer_size: 64 + +############################################# +# Enable the Home Assistant API +############################################# +api: + #encryption: + #key: !secret esp-?_api_key + +############################################# +# Enable Over the Air Update Capability +# Safe mode will detect boot loops +############################################# +ota: + safe_mode: true + password: !secret esp-mmwaveoffice_ota_pass + +############################################# +# Wifi Settings +############################################# +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + #power_save_mode: LIGHT #https://esphome.io/components/wifi.html#wifi-power-save-mode + #manual_ip: + #static_ip: 192.168.x.x + #gateway: 192.168.X.x + #subnet: 255.255.255.0 + #ap: #Details for fallback hotspot (captive portal) in case wifi connection fails + #ssid: "? Fallback Hotspot" + #password: !secret fallback_ap_password + +############################################# +# Web Portal for display and monitoring +# Turning this off is probably a good idea to save resources. +############################################# +web_server: + port: 80 +# username: !secret web_server_username +# password: !secret web_server_password + +############################################# +# MQTT Monitoring +############################################# +mqtt: + broker: !secret mqtt_server + topic_prefix: ${mqtt_topic}/${devicename} + username: !secret mqtt_username + password: !secret mqtt_password + +############################################# +############################################# +# MAIN SENSORS +############################################# +############################################# +uart: + id: LD1125H_UART_BUS + rx_pin: GPIO16 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + tx_pin: GPIO17 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# rx_pin: GPIO1 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang +# tx_pin: GPIO0 #For ESP32, you can use any pin, Recommend Use UART_2, Don't use UART_0, It might Cause Boot Fail or System Hang + baud_rate: 115200 + data_bits: 8 + stop_bits: 1 + parity: NONE +# debug: +# direction: BOTH +# dummy_receiver: false +# after: +# delimiter: "\n" +# sequence: +# - lambda: UARTDebug::log_string(direction, bytes); + +############################################# +# Global Variables for use in templates etc +############################################# +globals: + - id: LD1125H_Last_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Last_Mov_Time + type: time_t + restore_value: no + initial_value: time(NULL) + - id: LD1125H_Clearence_Status + type: bool + restore_value: no + initial_value: "false" + +############################################# +# General esp status LED +############################################# +status_led: + pin: + number: GPIO2 #ESP32 OnBroad LED + inverted: false + +############################################# +# Interval Automations +# https://esphome.io/guides/automations.html#interval-component +############################################# +interval: + - interval: 1s #Clearance Scan Time + setup_priority: -200 + then: + lambda: |- + if ((time(NULL)-id(LD1125H_Last_Time))>id(LD1125H_Clear_Time).state) { + if ((id(LD1125H_Clearence_Status) == false) || (id(LD1125H_Occupancy).state != "Clearance")) { + id(LD1125H_Occupancy).publish_state("Clearance"); + id(LD1125H_Clearence_Status) = true; + } + if (id(LD1125H_MovOcc_Binary).state == true) { + id(LD1125H_MovOcc_Binary).publish_state(false); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + +############################################# +# Number Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +number: + - platform: template + name: ${upper_devicename} LD1125H mth1 #mth1 is 0~2.8m Sensitivity. + id: LD1125H_mth1 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "60.0" #Default mth1 Setting + min_value: 10.0 + max_value: 600.0 + step: 5.0 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th1st = "mth1=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th1st.begin(), th1st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth2 #mth2 is 2.8~8m Sensitivity. + id: LD1125H_mth2 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "30" #Default mth2 Setting + min_value: 5 + max_value: 300 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th2st = "mth2=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th2st.begin(), th2st.end()); + - platform: template + name: ${upper_devicename} LD1125H mth3 #mth3 is above 8m Sensitivity. + id: LD1125H_mth3 + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "20" #Default mth3 Setting + min_value: 5 + max_value: 200 + step: 5 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string th3st = "mth3=" + str_sprintf("%.0f",x) +"\r\n"; + return std::vector(th3st.begin(), th3st.end()); + - platform: template + name: ${upper_devicename} LD1125H rmax #rmax is max detection distance. + id: LD1125H_rmax + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "8" #Default rmax Setting + min_value: 0.4 + max_value: 12 + step: 0.1 + set_action: + then: + - uart.write: + id: LD1125H_UART_BUS + data: !lambda |- + std::string rmaxst = "rmax=" + str_sprintf("%.1f",x) +"\r\n"; + return std::vector(rmaxst.begin(), rmaxst.end()); + - platform: template + name: ${upper_devicename} LD1125H Clearence Time + id: LD1125H_Clear_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "5" #LD1125H Mov/Occ > Clearence Time Here + min_value: 0.5 + max_value: 20 + step: 0.5 + - platform: template + name: ${upper_devicename} LD1125H Movement Time + id: LD1125H_Mov_Time + icon: "mdi:cogs" + optimistic: true + restore_value: true #If you don't want to store the setting at ESP, set it to false. + initial_value: "1" #LD1125H Mov > Occ Time Here + min_value: 0.5 + max_value: 10 + step: 0.5 + +############################################# +# General Sensors +# https://esphome.io/components/sensor/index.html +############################################# +sensor: + - platform: bme280_i2c + temperature: + name: ${upper_devicename} BME280 Temp + accuracy_decimals: 1 + oversampling: 2x + pressure: + name: ${upper_devicename} BME280 Pressure + oversampling: 2x + humidity: + name: ${upper_devicename} BME280 Humidity + accuracy_decimals: 1 + oversampling: 2x + address: 0x76 + update_interval: ${update_time} + - platform: uptime + name: ${upper_devicename} Uptime + - platform: template + name: ${upper_devicename} LD1125H Distance + id: LD1125H_Distance + icon: "mdi:signal-distance-variant" + unit_of_measurement: "m" + accuracy_decimals: 2 + filters: # Use Fliter To Debounce + - sliding_window_moving_average: + window_size: 8 + send_every: 2 + - heartbeat: 0.2s + +############################################# +# Text Sensors (custom component) +# refer https://github.com/ssieb/esphome_components/tree/master/components/serial +############################################# +text_sensor: + - platform: serial + uart_id: LD1125H_UART_BUS + name: ${upper_devicename} LD1125H UART Text + id: LD1125H_UART_Text + icon: "mdi:format-text" + internal: True #If Don't Want to See UART Receive Data, Set To True + on_value: + lambda: |- + if (id(LD1125H_UART_Text).state.substr(0,3) == "occ") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + if ((time(NULL)-id(LD1125H_Last_Mov_Time))>id(LD1125H_Mov_Time).state) { + id(LD1125H_Occupancy).publish_state("Occupancy"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == true) { + id(LD1125H_Mov_Binary).publish_state(false); + } + } + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + else if (id(LD1125H_UART_Text).state.substr(0,3) == "mov") { + id(LD1125H_Distance).publish_state(atof(id(LD1125H_UART_Text).state.substr(9).c_str())); + id(LD1125H_Occupancy).publish_state("Movement"); + if (id(LD1125H_MovOcc_Binary).state == false) { + id(LD1125H_MovOcc_Binary).publish_state(true); + } + if (id(LD1125H_Mov_Binary).state == false) { + id(LD1125H_Mov_Binary).publish_state(true); + } + id(LD1125H_Last_Mov_Time) = time(NULL); + id(LD1125H_Last_Time) = time(NULL); + if (id(LD1125H_Clearence_Status) == true) { + id(LD1125H_Clearence_Status) = false; + } + } + - platform: template + name: ${upper_devicename} LD1125H Occupancy Status + id: LD1125H_Occupancy + icon: "mdi:motion-sensor" + +############################################# +# Binary Sensors +# https://esphome.io/components/binary_sensor/index.html +############################################# +binary_sensor: + - platform: status + name: ${upper_devicename} Status + - platform: template + name: ${upper_devicename} LD1125H Occupancy or Movement + id: LD1125H_MovOcc_Binary + device_class: occupancy + - platform: template + name: ${upper_devicename} LD1125H Movement + id: LD1125H_Mov_Binary + device_class: motion \ No newline at end of file diff --git a/packages/covid_count.yaml b/packages/covid_count.yaml deleted file mode 100644 index c52fa2d..0000000 --- a/packages/covid_count.yaml +++ /dev/null @@ -1,55 +0,0 @@ -var: - covid_daily: - friendly_name: "Daily Covid count" - initial_value: 0 - icon: mdi:virus-outline - covid_yesterday_total: - friendly_name: "Yesterdays NZ Cumulative Total Covid Cases" - initial_value: 0 - icon: mdi:virus-outline - -automation: - - id: add_covid_confirmed_stats_only_if_increases - alias: add_covid_confirmed_stats_only_if_increases - #description: - # "Check new state of sensor.new_zealand_coronavirus_confirmed and store it - # in input_number.new_zealand_coronavirus_confirmed_previous_value if it has increased" - trigger: - - platform: state - entity_id: sensor.new_zealand_coronavirus_confirmed - condition: - - condition: template - value_template: - "{{ (states('sensor.new_zealand_coronavirus_confirmed') | float - > states('var.covid_yesterday_total') | float) }}" - action: - - service: var.set - data_template: - entity_id: var.covid_daily - value: - "{{ states('sensor.new_zealand_coronavirus_confirmed') | float - states('var.covid_yesterday_total') - | float }}" - - service: var.set - data_template: - entity_id: var.covid_yesterday_total - value: "{{ states('sensor.new_zealand_coronavirus_confirmed') | float }}" - -sensor: - - platform: statistics - entity_id: sensor.coronavirus_totals_normalised - sampling_size: 200000 - state_characteristic: mean - max_age: - days: 1 - name: "Coronavirus Statistics" - - platform: template - sensors: - coronavirus_totals_normalised: - friendly_name: "NZ Coronavirus Totals (Normalised)" - value_template: > - {% set new_state = states('sensor.new_zealand_coronavirus_confirmed') | float %} - {% if new_state >= states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float %} - {{ new_state }} - {% else %} - {{ states('input_number.new_zealand_coronavirus_confirmed_previous_value') | float }} - {% endif %} diff --git a/packages/ev_charging.yaml b/packages/ev_charging.yaml index 12c95da..8af80d7 100644 --- a/packages/ev_charging.yaml +++ b/packages/ev_charging.yaml @@ -1,27 +1,39 @@ mqtt: sensor: - - unique_id: 32a_ev_charger_power - name: "32A EV Charger Power" + - unique_id: 32a_ev_wallcharger_power + name: "32A EV Wallcharger Power" + device_class: power + unit_of_measurement: kW state_topic: "stat/tasmo-wemosd1-7280-powermon-1/EnergyMeterCount" - value_template: "{{ value_json.EVChargerWhCount * 2 * 60 }}" - - unique_id: 16a_ev_charger_power - name: "16A EV Charger Power" + value_template: "{{ value_json.EVChargerWhCount * 2 * 60 / 1000 }}" + - unique_id: 16a_ev_wallcharger_power + name: "16A EV Wallcharger Power" + device_class: power + unit_of_measurement: kW state_topic: "stat/tasmo-s4chan-7594-garage-1/EnergyMeterCount" - value_template: "{{ value_json.EVChargerWhCount * 2 * 60 }}" + value_template: "{{ value_json.EVChargerWhCount * 2 * 60 / 1000 }}" +# Use the Riemann sum integral to calculate energy in kWh +# from the contimuous power measuring sensors sensor: - platform: integration - unique_id: 32a_ev_charger_power_total - name: "32A EV Charger Power Total" - source: sensor.32a_ev_charger_power - #unit_prefix: k - #round: 2 + unique_id: 32a_ev_wallcharger_power_total + name: "32A EV Wallcharger Power Total" + source: sensor.32a_ev_wallcharger_power + #device_class: energy + #unit_of_measurement: Wh + #unit_time: h + #unit_prefix: k # Show in kWh + round: 0 # Only need 0 decimals accuracy - platform: integration - unique_id: 16a_ev_charger_power_total - name: "16A EV Charger Power Total" - source: sensor.16a_ev_charger_power + unique_id: 16a_ev_wallcharger_power_total + name: "16A EV Wallcharger Power Total" + source: sensor.16a_ev_wallcharger_power + #device_class: energy + #unit_of_measurement: Wh + #unit_time: h #unit_prefix: k - #round: 2 + round: 0 input_select: leaf_ev_charging_mode: diff --git a/packages/foxhole_controls.yaml b/packages/foxhole_controls.yaml new file mode 100644 index 0000000..93a0c3f --- /dev/null +++ b/packages/foxhole_controls.yaml @@ -0,0 +1,4 @@ +input_boolean: + foxhole_occupied: + name: Foxhole Guest Occupied + icon: mdi:briefcase-plus-outline diff --git a/packages/google_keep.yaml b/packages/google_keep.yaml deleted file mode 100644 index fa7d3b7..0000000 --- a/packages/google_keep.yaml +++ /dev/null @@ -1,7 +0,0 @@ -sensor: - - platform: google_keep - username: !secret google_keep.username - password: !secret google_keep.password - labels: - - "Home Assistant" - pinned: true diff --git a/packages/mqtt_statestream.yaml b/packages/mqtt_statestream.yaml new file mode 100644 index 0000000..e911487 --- /dev/null +++ b/packages/mqtt_statestream.yaml @@ -0,0 +1,12 @@ +mqtt_statestream: + base_topic: hamqtt + publish_attributes: true + publish_timestamps: true + include: + entities: + - sensor.main_bathroom_humidity_change_rate + entity_globs: + - sensor.*_zt* + #exclude: + # entity_globs: + # - sensor.*zoruno* diff --git a/packages/office_media_buttons.yaml b/packages/office_media_buttons.yaml index 90fc3d9..85ca457 100644 --- a/packages/office_media_buttons.yaml +++ b/packages/office_media_buttons.yaml @@ -7,32 +7,61 @@ # value_template: "{{ value_json.ZbReceived.Office_Media_Button.Power }}" automation: - - id: "1629271273952" + - id: pause_office_tv_on_media_button alias: Pause Office TV on Media Button description: "" trigger: - - platform: state - entity_id: sensor.media_button_office_zbt04_action - to: "single" + - platform: event + event_type: zha_event + event_data: + device_ieee: 00:15:8d:00:06:79:46:c8 + command: click + args: + click_type: single condition: [] action: - service: media_player.media_pause target: device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa mode: single - - id: "1629271457675" + - id: play_office_tv_on_media_button alias: Play Office TV on Media Button description: "" trigger: - - platform: state - entity_id: sensor.media_button_office_zbt04_action - to: "double" + - platform: event + event_type: zha_event + event_data: + device_ieee: 00:15:8d:00:06:79:46:c8 + command: click + args: + click_type: double condition: [] action: - service: media_player.media_play target: device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa mode: single + - id: seek_office_tv_on_media_button + alias: Seek Office TV on Media Button + description: "" + trigger: + - platform: event + event_type: zha_event + event_data: + device_ieee: 00:15:8d:00:06:79:46:c8 + command: click + args: + click_type: triple + condition: [] + action: + - service: media_player.media_seek + data: + seek_position: >- + {{ state_attr("media_player.office_tv", + "media_position")|int + (seek_amount|default(-30)|int(-30)) }} + target: + device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa + mode: single # - id: "1629271273958" # alias: Pause office TV on MQTT # description: "" @@ -60,3 +89,32 @@ automation: # data: # seek_position: 30 # mode: single + +#automation: +# - id: "1629271273952" +# unique_id: pause_office_tv_on_media_button +# alias: Pause Office TV on Media Button +# description: "" +# trigger: +# - platform: state +# entity_id: sensor.media_button_office_zbt04_action +# to: "single" +# condition: [] +# action: +# - service: media_player.media_pause +# target: +# device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa +# mode: single +# - id: "1629271457675" +# alias: Play Office TV on Media Button +# description: "" +# trigger: +# - platform: state +# entity_id: sensor.media_button_office_zbt04_action +# to: "double" +# condition: [] +# action: +# - service: media_player.media_play +# target: +# device_id: abb6b5a6b4e4925dcb3a77ea2c293eaa +# mode: single diff --git a/packages/pool_controls.yaml b/packages/pool_controls.yaml index aeb2610..651d8a5 100644 --- a/packages/pool_controls.yaml +++ b/packages/pool_controls.yaml @@ -1,3 +1,11 @@ +sensor: + - platform: integration + unique_id: pool_pump_power_total + name: "Pool pump power total" + source: sensor.tasmo_athplug_5853_3_poolpump_energy_power + unit_prefix: k + #round: 2 + input_select: pool_light_colour_select: icon: mdi:swimming-pool diff --git a/packages/presense_sense.yaml b/packages/presense_sense.yaml index b4a1053..dc691fc 100644 --- a/packages/presense_sense.yaml +++ b/packages/presense_sense.yaml @@ -75,3 +75,24 @@ sensor: state_topic: !secret btb09_topic timeout: 60 away_timeout: 120 # number of seconds after which the enitity will get status not_home + - platform: mqtt_room + unique_id: !secret btb10_uID + device_id: !secret btb10_dID + name: !secret btb10_name + state_topic: !secret btb10_topic + timeout: 60 + away_timeout: 120 # number of seconds after which the enitity will get status not_home + - platform: mqtt_room + unique_id: !secret btb11_uID + device_id: !secret btb11_dID + name: !secret btb11_name + state_topic: !secret btb11_topic + timeout: 60 + away_timeout: 120 # number of seconds after which the enitity will get status not_home + - platform: mqtt_room + unique_id: !secret btb12_uID + device_id: !secret btb12_dID + name: !secret btb12_name + state_topic: !secret btb12_topic + timeout: 60 + away_timeout: 120 # number of seconds after which the enitity will get status not_home diff --git a/packages/security_and_notifications.yaml b/packages/security_and_notifications.yaml new file mode 100644 index 0000000..b263c44 --- /dev/null +++ b/packages/security_and_notifications.yaml @@ -0,0 +1,7 @@ +input_boolean: + quiet_time: + name: Quiet time for no notifications + icon: mdi:shield-moon + away_occupied_routine: + name: Automation for Lights etc when away + icon: mdi:shield-lock diff --git a/packages/shower_controls.yaml b/packages/shower_controls.yaml new file mode 100644 index 0000000..6ec5813 --- /dev/null +++ b/packages/shower_controls.yaml @@ -0,0 +1,7 @@ +sensor: + - platform: derivative + name: Main Bathroom Humidity Change Rate + source: sensor.main_bathroom_environment_zth04_humidity + round: 1 + unit_time: s # the resulting "unit_of_measurement" will be %H/s if the sensor.temperate has set %H as its unit + time_window: "00:00:10" # we look at the change over the last 10 seconds diff --git a/packages/tautulli.yaml b/packages/tautulli.yaml new file mode 100644 index 0000000..77c5801 --- /dev/null +++ b/packages/tautulli.yaml @@ -0,0 +1,5 @@ +sensor: + - platform: tautulli + api_key: !secret tautulli_api_key + host: !secret tautulli_api_host + port: !secret tautulli_api_port diff --git a/packages/waste_collection.yaml b/packages/waste_collection.yaml index 9365af4..4688173 100644 --- a/packages/waste_collection.yaml +++ b/packages/waste_collection.yaml @@ -3,3 +3,53 @@ waste_collection_schedule: - name: aucklandcouncil_govt_nz args: area_number: 12344403722 # see 'How to get the source argument below' + +sensor: + - platform: waste_collection_schedule + #source_index: 0 + name: Auckland Council Waste + details_format: upcoming + count: 1 + leadtime: 1 + #value_template: VALUE_TEMPLATE + #date_template: DATE_TEMPLATE + add_days_to: true + #event_index: EVENT_INDEX + types: + - rubbish + - platform: waste_collection_schedule + #source_index: 0 + name: Auckland Council Recycling + details_format: upcoming + count: 1 + leadtime: 1 + #value_template: VALUE_TEMPLATE + #date_template: DATE_TEMPLATE + add_days_to: true + #event_index: EVENT_INDEX + types: + - recycle + - platform: waste_collection_schedule + #source_index: 0 + name: Auckland Council Food-Waste + details_format: upcoming + count: 1 + leadtime: 1 + #value_template: VALUE_TEMPLATE + #date_template: DATE_TEMPLATE + add_days_to: true + #event_index: EVENT_INDEX + types: + - food-waste + +mqtt: + sensor: + - unique_id: auckland_council_red_waste_bin_out + name: "Red Waste Bin Out" + state_topic: "viewroad-status/rubbishbinstatus/redbin-out" + - unique_id: auckland_council_green_recycling_bin_out + name: "Green Recycling Bin Out" + state_topic: "viewroad-status/rubbishbinstatus/greenbin-out" + - unique_id: auckland_council_food_waste_bin_out + name: "Food Waste Bin Out" + state_topic: "viewroad-status/rubbishbinstatus/foodbin-out" diff --git a/scripts/check_config.yaml b/scripts/check_config.yaml index f202c64..5e0df46 100644 --- a/scripts/check_config.yaml +++ b/scripts/check_config.yaml @@ -1,3 +1,3 @@ -check_config: - sequence: [] - alias: Check Configuration +#check_config: +# sequence: [] +# alias: Check Configuration diff --git a/scripts/zha.yaml b/scripts/zha.yaml new file mode 100644 index 0000000..4535aaa --- /dev/null +++ b/scripts/zha.yaml @@ -0,0 +1,2 @@ +zha: + custom_quirks_path: /config/custom_zha_quirks/